about summary refs log tree commit diff
path: root/benchtests/bench-util.h
diff options
context:
space:
mode:
authorAdhemerval Zanella Netto <adhemerval.zanella@linaro.org>2022-07-21 10:05:01 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2022-07-22 11:58:27 -0300
commit5d765ada01d140d8d1ecf94953a4751593af720d (patch)
treeec344761c986ebc53ae613c0417a929bfc1381b2 /benchtests/bench-util.h
parent8dd890d96f1833a58de6e112a14d63ab44e0a402 (diff)
downloadglibc-5d765ada01d140d8d1ecf94953a4751593af720d.tar.gz
glibc-5d765ada01d140d8d1ecf94953a4751593af720d.tar.xz
glibc-5d765ada01d140d8d1ecf94953a4751593af720d.zip
benchtests: Add arc4random benchtest
It shows both throughput (total bytes obtained in the test duration)
and latecy for both arc4random and arc4random_buf with different
sizes.

Checked on x86_64-linux-gnu, aarch64-linux, and powerpc64le-linux-gnu.
Diffstat (limited to 'benchtests/bench-util.h')
-rw-r--r--benchtests/bench-util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/benchtests/bench-util.h b/benchtests/bench-util.h
index d0e29423aa..00f78d649f 100644
--- a/benchtests/bench-util.h
+++ b/benchtests/bench-util.h
@@ -16,6 +16,13 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+/* Prevent compiler to optimize away call.  */
+#define DO_NOT_OPTIMIZE_OUT(value)		  \
+  ({						  \
+    __typeof (value) __v = (value);		  \
+    asm volatile ("" : : "r,m" (__v) : "memory"); \
+    __v;					  \
+  })
 
 #ifndef START_ITER
 # define START_ITER (100000000)