Add test cycles per loop
[urcu.git] / tests / test_cycles_per_loop.c
diff --git a/tests/test_cycles_per_loop.c b/tests/test_cycles_per_loop.c
new file mode 100644 (file)
index 0000000..64b160b
--- /dev/null
@@ -0,0 +1,21 @@
+#include <urcu/arch.h>
+#include <stdio.h>
+
+#define NR_LOOPS 1000000UL
+
+static inline void loop_sleep(unsigned long l)
+{
+       while(l-- != 0)
+               cpu_relax();
+}
+
+int main()
+{
+       cycles_t time1, time2;
+
+       time1 = get_cycles();
+       loop_sleep(NR_LOOPS);
+       time2 = get_cycles();
+       printf("CPU clock cycles per loop: %g\n", (time2 - time1) /
+                                                 (double)NR_LOOPS);
+}
This page took 0.022845 seconds and 4 git commands to generate.