source:
benchmark/fetch_add.c@
80eefcb
Last change on this file since 80eefcb was bf71cfd, checked in by , 7 years ago | |
---|---|
|
|
File size: 370 bytes |
Rev | Line | |
---|---|---|
[6aa537a4] | 1 | #include <stdio.h> |
2 | ||
3 | #include "bench.h" | |
4 | ||
5 | volatile int value; | |
6 | ||
7 | void __attribute__((noinline)) do_call() { | |
8 | __atomic_add_fetch( &value, 1, __ATOMIC_SEQ_CST ); | |
9 | asm volatile (""); | |
10 | __atomic_sub_fetch( &value, 1, __ATOMIC_SEQ_CST ); | |
11 | } | |
12 | ||
13 | int main(int argc, char* argv[]) { | |
14 | BENCH( | |
15 | for (size_t i = 0; i < n; i++) { | |
16 | do_call(); | |
17 | }, | |
18 | result | |
19 | ) | |
20 | ||
21 | printf("%llu\n", result); | |
22 | } |
Note:
See TracBrowser
for help on using the repository browser.