X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=tests%2Ftest_cycles_per_loop.c;fp=tests%2Ftest_cycles_per_loop.c;h=64b160b775ca63233569c9b680f8997dcb8bbc45;hb=d3d3d8f0136d7c095bdf97b17ec3f1d7a1b1dfe6;hp=0000000000000000000000000000000000000000;hpb=8c3cea9493eb7c10aa855f6fa73725705f7bc349;p=urcu.git diff --git a/tests/test_cycles_per_loop.c b/tests/test_cycles_per_loop.c new file mode 100644 index 0000000..64b160b --- /dev/null +++ b/tests/test_cycles_per_loop.c @@ -0,0 +1,21 @@ +#include +#include + +#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); +}