summaryrefslogtreecommitdiff
path: root/test/testlockperf.c
diff options
context:
space:
mode:
authorJeff Trawick <trawick@apache.org>2013-10-12 16:06:15 +0000
committerJeff Trawick <trawick@apache.org>2013-10-12 16:06:15 +0000
commit6becfa029f279e264da2d35eba881e7abc866bea (patch)
treedbadc51a0b2e411ccd9a539dd9fa6e9bd4d76578 /test/testlockperf.c
parentea2331ce29ab6d1bd450aaeaae2b23f2303f693a (diff)
downloadapr-6becfa029f279e264da2d35eba881e7abc866bea.tar.gz
don't spend 10 minutes in testlockperf during make test/check on Windows
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1531554 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testlockperf.c')
-rw-r--r--test/testlockperf.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/test/testlockperf.c b/test/testlockperf.c
index 84c0ba991..6cca99d16 100644
--- a/test/testlockperf.c
+++ b/test/testlockperf.c
@@ -35,11 +35,12 @@ int main(void)
}
#else /* !APR_HAS_THREADS */
-#define MAX_COUNTER 1000000
+#define DEFAULT_MAX_COUNTER 1000000
#define MAX_THREADS 6
static int verbose = 0;
static long mutex_counter;
+static long max_counter = DEFAULT_MAX_COUNTER;
static apr_thread_mutex_t *thread_lock;
void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data);
@@ -58,7 +59,7 @@ void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data)
{
int i;
- for (i = 0; i < MAX_COUNTER; i++) {
+ for (i = 0; i < max_counter; i++) {
apr_thread_mutex_lock(thread_lock);
mutex_counter++;
apr_thread_mutex_unlock(thread_lock);
@@ -70,7 +71,7 @@ void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data)
{
int i;
- for (i = 0; i < MAX_COUNTER; i++) {
+ for (i = 0; i < max_counter; i++) {
apr_thread_rwlock_wrlock(thread_rwlock);
mutex_counter++;
apr_thread_rwlock_unlock(thread_rwlock);
@@ -120,7 +121,7 @@ int test_thread_mutex(int num_threads)
time_stop = apr_time_now();
printf("microseconds: %" APR_INT64_T_FMT " usec\n",
(time_stop - time_start));
- if (mutex_counter != MAX_COUNTER * num_threads)
+ if (mutex_counter != max_counter * num_threads)
printf("error: counter = %ld\n", mutex_counter);
return APR_SUCCESS;
@@ -168,7 +169,7 @@ int test_thread_mutex_nested(int num_threads)
time_stop = apr_time_now();
printf("microseconds: %" APR_INT64_T_FMT " usec\n",
(time_stop - time_start));
- if (mutex_counter != MAX_COUNTER * num_threads)
+ if (mutex_counter != max_counter * num_threads)
printf("error: counter = %ld\n", mutex_counter);
return APR_SUCCESS;
@@ -216,7 +217,7 @@ int test_thread_rwlock(int num_threads)
time_stop = apr_time_now();
printf("microseconds: %" APR_INT64_T_FMT " usec\n",
(time_stop - time_start));
- if (mutex_counter != MAX_COUNTER * num_threads)
+ if (mutex_counter != max_counter * num_threads)
printf("error: counter = %ld\n", mutex_counter);
return APR_SUCCESS;
@@ -244,8 +245,11 @@ int main(int argc, const char * const *argv)
exit(-1);
}
- while ((rv = apr_getopt(opt, "v", &optchar, &optarg)) == APR_SUCCESS) {
- if (optchar == 'v') {
+ while ((rv = apr_getopt(opt, "c:v", &optchar, &optarg)) == APR_SUCCESS) {
+ if (optchar == 'c') {
+ max_counter = atol(optarg);
+ }
+ else if (optchar == 'v') {
verbose = 1;
}
}