MCPcopy Create free account
hub / github.com/cinder/Cinder / benchStdFunctionCallbackLoop

Function benchStdFunctionCallbackLoop

test/SignalsTest/src/SignalsBenchmark.cpp:129–147  ·  view source on GitHub ↗

the time of a std::function callback

Source from the content-addressed store, hash-verified

127
128// the time of a std::function callback
129static 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
149int main()
150{

Callers 1

mainFunction · 0.85

Calls 3

timestampBenchmarkFunction · 0.85
assertFunction · 0.85
getFunction · 0.50

Tested by

no test coverage detected