uatomic/x86: Remove redundant memory barriers
[urcu.git] / tests / benchmark / test_cycles_per_loop.c
CommitLineData
ce29b371
MJ
1// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2//
3// SPDX-License-Identifier: GPL-2.0-or-later
4
3282a76b 5/*
3282a76b 6 * Userspace RCU library - test cycles per loop
3282a76b
MD
7 */
8
d3d3d8f0
MD
9#include <urcu/arch.h>
10#include <stdio.h>
11
12#define NR_LOOPS 1000000UL
13
ab0aacbe 14static inline void loop_sleep(unsigned long loops)
d3d3d8f0 15{
ab0aacbe 16 while (loops-- != 0)
06f22bdb 17 caa_cpu_relax();
d3d3d8f0
MD
18}
19
20int main()
21{
3fa18286 22 caa_cycles_t time1, time2;
d3d3d8f0 23
06f22bdb 24 time1 = caa_get_cycles();
d3d3d8f0 25 loop_sleep(NR_LOOPS);
06f22bdb 26 time2 = caa_get_cycles();
d3d3d8f0
MD
27 printf("CPU clock cycles per loop: %g\n", (time2 - time1) /
28 (double)NR_LOOPS);
9907018c 29 return 0;
d3d3d8f0 30}
This page took 0.043736 seconds and 4 git commands to generate.