printf("pthread_mutex_lock took %9.3fus for %d ops: %9.3fus/lock (%9.3fMops/s)\n",tdiff(&start,&end),K,tdiff(&start,&end)/K,K/tdiff(&start,&end));
gettimeofday(&start,0);
for(i=0;i<K;i++){
r=pthread_mutex_unlock(&mlocks[i]);
assert(r==0);
}
gettimeofday(&end,0);
printf("pthread_mutex_unlock took %9.3fus for %d ops: %9.3fus/lock (%9.3fMops/s)\n",tdiff(&start,&end),K,tdiff(&start,&end)/K,K/tdiff(&start,&end));
}
for(j=0;j<3;j++){
for(i=0;i<K;i++){
r=pthread_rwlock_init(&rwlocks[i],NULL);
assert(r==0);
}
gettimeofday(&start,0);
for(i=0;i<K;i++){
r=pthread_rwlock_tryrdlock(&rwlocks[i]);
assert(r==0);
}
gettimeofday(&end,0);
printf("pthread_rwlock_tryrdlock took %9.3fus for %d ops: %9.3fus/lock (%9.3fMops/s)\n",tdiff(&start,&end),K,tdiff(&start,&end)/K,K/tdiff(&start,&end));
}
for(j=0;j<3;j++){
for(i=0;i<K;i++){
r=pthread_rwlock_init(&rwlocks[i],NULL);
assert(r==0);
}
gettimeofday(&start,0);
for(i=0;i<K;i++){
r=pthread_rwlock_rdlock(&rwlocks[i]);
assert(r==0);
}
gettimeofday(&end,0);
printf("pthread_rwlock_rdlock took %9.3fus for %d ops: %9.3fus/lock (%9.3fMops/s)\n",tdiff(&start,&end),K,tdiff(&start,&end)/K,K/tdiff(&start,&end));
}
for(j=0;j<3;j++){
for(i=0;i<K;i++){
blocks[i].state=0;
blocks[i].mutex=0;
}
gettimeofday(&start,0);
for(i=0;i<K;i++){
brwl_rlock_xchg(&blocks[i]);
}
gettimeofday(&end,0);
printf("brwl_rlock_xchg took %9.3fus for %d ops: %9.3fus/lock (%9.3fMops/s)\n",tdiff(&start,&end),K,tdiff(&start,&end)/K,K/tdiff(&start,&end));
}
for(j=0;j<3;j++){
for(i=0;i<K;i++){
blocks[i].state=0;
blocks[i].mutex=0;
}
gettimeofday(&start,0);
for(i=0;i<K;i++){
brwl_rlock_fence(&blocks[i]);
}
gettimeofday(&end,0);
printf("brwl_rlock_fence took %9.3fus for %d ops: %9.3fus/lock (%9.3fMops/s)\n",tdiff(&start,&end),K,tdiff(&start,&end)/K,K/tdiff(&start,&end));