1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
#include "MainFrameTimer.h"
namespace tracing {
MainFrameTimer::MainFrameTimer() : _out("profiling.csv") {
}
MainFrameTimer::~MainFrameTimer() {
_out.close();
}
void MainFrameTimer::processEvent(const trace_event* event) {
if (event->scope != &MainFrameScope || event->category != &MainFrame) {
return;
}
switch(event->type) {
case EventType::AsyncBegin:
_begin_time = event->timestamp;
break;
case EventType::AsyncEnd:
{
auto end = event->timestamp;
auto duration = event->timestamp - _begin_time;
_out << end << ";" << duration << "\n";
break;
}
default:
// Ignore everything else
return;
}
}
}
|