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

Method testPerformance

test/DebugTest/src/DebugTestApp.cpp:213–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213void DebugTestApp::testPerformance()
214{
215
216 log::manager()->restoreToDefault();
217 CI_LOG_I( "\n--- TESTING PERFORMANCE START----");
218 CI_LOG_I( "... this may take a while, don't fret." );
219
220 log::manager()->clearLoggers();
221
222 typedef struct {
223 double duration;
224 int hits;
225 } LogMeasure;
226
227 auto looper = [](std::string log, LogMeasure &stats ) {
228
229 shared_ptr<log::LoggerFile> logger = nullptr;
230 if( !log.empty() ) {
231 logger = log::makeLogger<log::LoggerFile>( log, false );
232 }
233 int logHits = 0;
234 ci::Timer timer;
235 timer.start();
236 for( int i=0; i<1000; ++i ) {
237 for( int j=0; j<1000; ++j ) {
238 CI_LOG_D( ++logHits );
239 }
240 }
241 timer.stop();
242
243 if( logger ) {
244 // clean up our mess
245 auto path = logger->getFilePath();
246 log::manager()->removeLogger( logger );
247 logger.reset();
248 fs::remove( path );
249 }
250
251 stats.hits = logHits;
252 stats.duration = timer.getSeconds();
253 };
254
255 LogMeasure run1, run2, run3, run4, run5, run6;
256
257 // test single log single thread
258 looper( "/tmp/performance.log", run1 );
259
260 // test two threads single log
261 std::thread t1( [ looper, &run2 ] () { looper( "/tmp/performance.log", run2 ); } );
262 std::thread t2( [ looper, &run3 ] () { looper( "", run3 ); } );
263
264 t1.join();
265 t2.join();
266
267 // test three threads single log
268 std::thread t3( [ looper, &run4 ] () { looper( "/tmp/performance.log", run4 ); } );
269 std::thread t4( [ looper, &run5 ] () { looper( "", run5 ); } );
270 std::thread t5( [ looper, &run6 ] () { looper( "", run6 ); } );

Callers

nothing calls this directly

Calls 13

managerFunction · 0.85
removeFunction · 0.85
restoreToDefaultMethod · 0.80
clearLoggersMethod · 0.80
removeLoggerMethod · 0.80
getSecondsMethod · 0.80
maxFunction · 0.50
emptyMethod · 0.45
startMethod · 0.45
stopMethod · 0.45
resetMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected