source:
benchmark/basic/fetch_add.c
@
50cfa99
Last change on this file since 50cfa99 was b4107c8, checked in by , 4 years ago | |
---|---|
|
|
File size: 445 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 | ||
[b4107c8] | 13 | int main( int argc, char * argv[] ) { |
14 | BENCH_START() | |
[6aa537a4] | 15 | BENCH( |
[b4107c8] | 16 | for (size_t i = 0; i < times; i++) { |
[6aa537a4] | 17 | do_call(); |
18 | }, | |
19 | result | |
20 | ) | |
[b4107c8] | 21 | printf( "%g\n", result ); |
[6aa537a4] | 22 | } |
[b4107c8] | 23 | |
24 | // Local Variables: // | |
25 | // tab-width: 4 // | |
26 | // End: // |
Note: See TracBrowser
for help on using the repository browser.