the time of a std::function callback
| 127 | |
| 128 | // the time of a std::function callback |
| 129 | static void benchStdFunctionCallbackLoop() |
| 130 | { |
| 131 | void *someData = nullptr; |
| 132 | std::function<void( uint64_t )> counterIncrement = [someData]( uint64_t incr ) { TestCounter::add2( someData, 1 ); }; |
| 133 | |
| 134 | const uint64_t startCounter = TestCounter::get(); |
| 135 | const uint64_t benchStart = timestampBenchmark(); |
| 136 | |
| 137 | uint64_t i; |
| 138 | for( i = 0; i < 1000000; i++ ) |
| 139 | counterIncrement( 1 ); |
| 140 | |
| 141 | const uint64_t benchDone = timestampBenchmark(); |
| 142 | const uint64_t endCounter = TestCounter::get(); |
| 143 | assert( endCounter - startCounter == i ); |
| 144 | |
| 145 | cout << "OK" << endl; |
| 146 | cout << "\tper round: " << double( benchDone - benchStart ) / double( i ) << "ns" << endl; |
| 147 | } |
| 148 | |
| 149 | int main() |
| 150 | { |
no test coverage detected