namespace
{ void trace_event_test()
{
{ // When we start recording is off and this will not generate any 'X' event when we leave the scope
comphelper::ProfileZone aZone0("test0");
// This will not generate any 'b' and 'e' events either auto pAsync1(std::make_shared<comphelper::AsyncEvent>("async1"));
{ // No 'X' by this either
comphelper::ProfileZone aZone1("block1");
// Now we turn on recording
comphelper::TraceEvent::startRecording();
}
// This will generate an 'i' event for instant1
comphelper::TraceEvent::addInstantEvent("instant1");
// This does not generate any 'e' event as it was created when recording was off // And the nested async2 object will thus not generate anything either
pAsync1.reset();
// This will generate 'b' event and an 'e' event when the pointer is reset or goes out of scope
pAsync25 = std::make_shared<comphelper::AsyncEvent>("async2.5");
// Leaving this scope will generate an 'X' event for block2
}
// This will generate a 'b' event for async3
std::map<OUString, OUString> aArgsAsync3({ { "foo", "bar" }, { "tem", "42" } }); auto pAsync3(std::make_shared<comphelper::AsyncEvent>("async3", aArgsAsync3));
{
comphelper::ProfileZone aZone3("block3");
// Leaving this scope will generate an 'X' event for block3
}
// This will generate an 'e' event for async2.5
pAsync25.reset();
comphelper::ProfileZone aZone4("test2");
// This will generate an 'i' event for instant2"
std::map<OUString, OUString> aArgsInstant2({ { "foo2", "bar2" }, { "tem2", "42" } });
comphelper::TraceEvent::addInstantEvent("instant2", aArgsInstant2);
// Leaving this scope will generate 'X' events for test2 and a // 'e' event for async4in3, async7in3, and async3.
}
// This incorrect use of overlapping (not nested) ProfileZones // will generate a SAL_WARN but should not crash auto p1 = new comphelper::ProfileZone("error1"); auto p2 = new comphelper::ProfileZone("error2"); delete p1; delete p2;
}
}
void TestTraceEvent::test()
{
trace_event_test(); auto aEvents = comphelper::TraceEvent::getEventVectorAndClear(); for (constauto& s : aEvents)
{
std::cerr << s << "\n";
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.