#include #include "bench.h" // Does a "lock add" on entry and a "lock sub" on exit => 2 atomic instructions making it the most expensive // atomic test. volatile int value; void __attribute__((noinline)) do_call() { __atomic_add_fetch( &value, 1, __ATOMIC_SEQ_CST ); asm volatile (""); __atomic_sub_fetch( &value, 1, __ATOMIC_SEQ_CST ); } int main( int argc, char * argv[] ) { BENCH_START() BENCH( for (size_t i = 0; i < times; i++) { do_call(); }, result ) printf( "%g\n", result ); } // Local Variables: // // tab-width: 4 // // End: //