"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/testlockperf.c" between
apr-1.6.5.tar.bz2 and apr-1.7.0.tar.bz2

About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).

testlockperf.c  (apr-1.6.5.tar.bz2):testlockperf.c  (apr-1.7.0.tar.bz2)
skipping to change at line 63 skipping to change at line 63
int test_thread_mutex_nested(int num_threads); int test_thread_mutex_nested(int num_threads);
apr_pool_t *pool; apr_pool_t *pool;
int i = 0, x = 0; int i = 0, x = 0;
void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data) void * APR_THREAD_FUNC thread_mutex_func(apr_thread_t *thd, void *data)
{ {
int i; int i;
for (i = 0; i < max_counter; i++) { for (i = 0; i < max_counter; i++) {
apr_thread_mutex_lock(thread_lock); if (data) {
apr_thread_mutex_timedlock(thread_lock, *(apr_interval_time_t *)data
);
}
else {
apr_thread_mutex_lock(thread_lock);
}
mutex_counter++; mutex_counter++;
apr_thread_mutex_unlock(thread_lock); apr_thread_mutex_unlock(thread_lock);
} }
return NULL; return NULL;
} }
void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data) void * APR_THREAD_FUNC thread_rwlock_func(apr_thread_t *thd, void *data)
{ {
int i; int i;
skipping to change at line 178 skipping to change at line 183
time_stop = apr_time_now(); time_stop = apr_time_now();
printf("microseconds: %" APR_INT64_T_FMT " usec\n", printf("microseconds: %" APR_INT64_T_FMT " usec\n",
(time_stop - time_start)); (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); printf("error: counter = %ld\n", mutex_counter);
return APR_SUCCESS; return APR_SUCCESS;
} }
static int test_thread_mutex_timed(int num_threads)
{
apr_thread_t *t[MAX_THREADS];
apr_status_t s[MAX_THREADS];
apr_time_t time_start, time_stop;
apr_time_t timeout;
int i;
mutex_counter = 0;
timeout = apr_time_from_sec(5);
printf("apr_thread_mutex_t Tests\n");
printf("%-60s", " Initializing the apr_thread_mutex_t (TIMED)");
s[0] = apr_thread_mutex_create(&thread_lock, APR_THREAD_MUTEX_TIMED, pool);
if (s[0] != APR_SUCCESS) {
printf("Failed!\n");
return s[0];
}
printf("OK\n");
apr_thread_mutex_lock(thread_lock);
/* set_concurrency(4)? -aaron */
printf(" Starting %d threads ", num_threads);
for (i = 0; i < num_threads; ++i) {
s[i] = apr_thread_create(&t[i], NULL, thread_mutex_func, &timeout, pool)
;
if (s[i] != APR_SUCCESS) {
printf("Failed!\n");
return s[i];
}
}
printf("OK\n");
time_start = apr_time_now();
apr_thread_mutex_unlock(thread_lock);
/* printf("%-60s", " Waiting for threads to exit"); */
for (i = 0; i < num_threads; ++i) {
apr_thread_join(&s[i], t[i]);
}
/* printf("OK\n"); */
time_stop = apr_time_now();
printf("microseconds: %" APR_INT64_T_FMT " usec\n",
(time_stop - time_start));
if (mutex_counter != max_counter * num_threads)
printf("error: counter = %ld\n", mutex_counter);
return APR_SUCCESS;
}
int test_thread_rwlock(int num_threads) int test_thread_rwlock(int num_threads)
{ {
apr_thread_t *t[MAX_THREADS]; apr_thread_t *t[MAX_THREADS];
apr_status_t s[MAX_THREADS]; apr_status_t s[MAX_THREADS];
apr_time_t time_start, time_stop; apr_time_t time_start, time_stop;
int i; int i;
mutex_counter = 0; mutex_counter = 0;
printf("apr_thread_rwlock_t Tests\n"); printf("apr_thread_rwlock_t Tests\n");
skipping to change at line 276 skipping to change at line 332
rv, apr_strerror(rv, (char*)errmsg, 200)); rv, apr_strerror(rv, (char*)errmsg, 200));
exit(-3); exit(-3);
} }
if ((rv = test_thread_mutex_nested(i)) != APR_SUCCESS) { if ((rv = test_thread_mutex_nested(i)) != APR_SUCCESS) {
fprintf(stderr,"thread_mutex (NESTED) test failed : [%d] %s\n", fprintf(stderr,"thread_mutex (NESTED) test failed : [%d] %s\n",
rv, apr_strerror(rv, (char*)errmsg, 200)); rv, apr_strerror(rv, (char*)errmsg, 200));
exit(-4); exit(-4);
} }
if ((rv = test_thread_mutex_timed(i)) != APR_SUCCESS) {
fprintf(stderr,"thread_mutex (TIMED) test failed : [%d] %s\n",
rv, apr_strerror(rv, (char*)errmsg, 200));
exit(-5);
}
if ((rv = test_thread_rwlock(i)) != APR_SUCCESS) { if ((rv = test_thread_rwlock(i)) != APR_SUCCESS) {
fprintf(stderr,"thread_rwlock test failed : [%d] %s\n", fprintf(stderr,"thread_rwlock test failed : [%d] %s\n",
rv, apr_strerror(rv, (char*)errmsg, 200)); rv, apr_strerror(rv, (char*)errmsg, 200));
exit(-6); exit(-6);
} }
} }
return 0; return 0;
} }
 End of changes. 3 change blocks. 
1 lines changed or deleted 65 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)