[PATCH] Converted benchmark to benchtest.

Siddhesh Poyarekar siddhesh@redhat.com
Thu Jun 5 12:36:00 GMT 2014


On Sat, May 03, 2014 at 12:48:31PM +0200, Ondřej Bílka wrote:
> Its nice to have but orthogonal on proposed change, so it should not
> block this patch

This looks like something that could easily use the $bench-inputs
format since you're really just looking for mean times.  I haven't
checked to see if a failed branch would be expensive compared to the
lock/unlock cycle we're testing, but I'm guessing that it should get
cached and hence not have an impact since we don't interleave the
rdlock and wrlock calls.

Siddhesh

diff --git a/benchtests/Makefile b/benchtests/Makefile
index 63a5a7f..d74de80 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -25,7 +25,7 @@ include ../Makeconfig
 bench-math := acos acosh asin asinh atan atanh cos cosh exp exp2 ffs ffsll \
 	      log log2 modf pow rint sin sincos sinh sqrt tan tanh
 
-bench-pthread := pthread_once
+bench-pthread := pthread_once pthread_rwlock_test
 
 bench := $(bench-math) $(bench-pthread)
 
diff --git a/benchtests/pthread_rwlock_test-inputs b/benchtests/pthread_rwlock_test-inputs
new file mode 100644
index 0000000..9122afb
--- /dev/null
+++ b/benchtests/pthread_rwlock_test-inputs
@@ -0,0 +1,8 @@
+## args: int
+## includes: pthread.h
+## include-sources: pthread_rwlock_test-source.c
+
+##name: rdlock
+0
+##name: rwlock
+1
diff --git a/benchtests/pthread_rwlock_test-source.c b/benchtests/pthread_rwlock_test-source.c
new file mode 100644
index 0000000..c679f7b
--- /dev/null
+++ b/benchtests/pthread_rwlock_test-source.c
@@ -0,0 +1,13 @@
+
+static pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
+
+static void
+pthread_rwlock_test (int write)
+{
+  if (write)
+    pthread_rwlock_wrlock (&rwlock);
+  else
+    pthread_rwlock_rdlock (&rwlock);
+
+  pthread_rwlock_unlock (&rwlock);
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20140605/90dda091/attachment.sig>


More information about the Libc-alpha mailing list