summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-06-23 13:05:36 +0300
committerTor Lillqvist <tml@collabora.com>2021-07-15 09:02:23 +0200
commit9ff73bfc2411f201e022ffc5d73eb0f96768495e (patch)
treed7c825b5f26fe04b2acd1f36e3832b91990d2b7f /comphelper
parent6c411afae7f6cd9819c1b65d7b4212019a7b3cfe (diff)
The Chrome Trace Event viewer doesn't support nested async events
Instead of nestable b(egin) and e(nd) events, generate the allegedly deprecated S(tart)' and F(inish) events. Makes the code simpler. (And AsyncEvent is still unused. Unclear whether adding it was based on a misunderstanding.) Change-Id: Ic029b67e0951dda775c0d0af009f2e431ae55e53 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117700 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117737 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118911
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/qa/unit/test_traceevent.cxx67
1 files changed, 10 insertions, 57 deletions
diff --git a/comphelper/qa/unit/test_traceevent.cxx b/comphelper/qa/unit/test_traceevent.cxx
index 8bd34595e397..6f768c09d466 100644
--- a/comphelper/qa/unit/test_traceevent.cxx
+++ b/comphelper/qa/unit/test_traceevent.cxx
@@ -40,17 +40,12 @@ void trace_event_test()
// This will not generate any 'b' and 'e' events either
auto pAsync1(std::make_shared<comphelper::AsyncEvent>("async1"));
- std::weak_ptr<comphelper::AsyncEvent> pAsync2;
{
// No 'X' by this either
comphelper::ProfileZone aZone1("block1");
// Now we turn on recording
comphelper::TraceEvent::startRecording();
-
- // As this is nested in the parent that was created with recording turned off,
- // this will not generate any 'b' and 'e' events either even if recording is now on.
- pAsync2 = comphelper::AsyncEvent::createWithParent("async2in1", pAsync1);
}
// This will generate an 'i' event for instant1
@@ -70,20 +65,13 @@ void trace_event_test()
// Leaving this scope will generate an 'X' event for block2
}
- // Verify that the weak_ptr to pAsync2 has expired as its parent pAsync1 has been finished off
- CPPUNIT_ASSERT(pAsync2.expired());
-
// This will generate a 'b' event for async3
auto pAsync3(std::make_shared<comphelper::AsyncEvent>(
"async3", std::map<OUString, OUString>({ { "foo", "bar" }, { "tem", "42" } })));
- std::weak_ptr<comphelper::AsyncEvent> pAsync4;
-
{
comphelper::ProfileZone aZone3("block3");
- pAsync4 = comphelper::AsyncEvent::createWithParent("async4in3", pAsync3);
-
// Leaving this scope will generate an 'X' event for block3
}
@@ -96,32 +84,8 @@ void trace_event_test()
comphelper::TraceEvent::addInstantEvent(
"instant2", std::map<OUString, OUString>({ { "foo2", "bar2" }, { "tem2", "42" } }));
- std::weak_ptr<comphelper::AsyncEvent> pAsync5;
- {
- auto pAsync4Locked = pAsync4.lock();
- CPPUNIT_ASSERT(pAsync4Locked);
- // This will generate a 'b' event for async5in4
- pAsync5 = comphelper::AsyncEvent::createWithParent("async5in4", pAsync4Locked);
- }
-
- CPPUNIT_ASSERT(!pAsync5.expired());
-
- // This will generate a 'b' event for async6in5
- std::weak_ptr<comphelper::AsyncEvent> pAsync6(
- comphelper::AsyncEvent::createWithParent("async6in5", pAsync5.lock()));
- CPPUNIT_ASSERT(!pAsync6.expired());
-
- // This will generate an 'e' event for async6in5 and async5in4
- pAsync5.lock()->finish();
-
- pAsync7Locked = comphelper::AsyncEvent::createWithParent("async7in3", pAsync3).lock();
-
- CPPUNIT_ASSERT(pAsync6.expired());
-
// Leaving this scope will generate 'X' events for test2 and a
- // 'e' event for async4in3, async7in3, and async3. The
- // pAsync7Locked pointer will now point to an AsyncEvent
- // object that has already had its 'e' event generated.
+ // 'e' event for async4in3, async7in3, and async3.
}
// This incorrect use of overlapping (not nested) ProfileZones
@@ -130,9 +94,6 @@ void trace_event_test()
auto p2 = new comphelper::ProfileZone("error2");
delete p1;
delete p2;
-
- // Nothing is generated from this
- pAsync7Locked.reset();
}
}
@@ -145,28 +106,20 @@ void TestTraceEvent::test()
std::cerr << s << "\n";
}
- CPPUNIT_ASSERT_EQUAL(17, static_cast<int>(aEvents.size()));
+ CPPUNIT_ASSERT_EQUAL(9, static_cast<int>(aEvents.size()));
CPPUNIT_ASSERT(aEvents[0].startsWith("{\"name:\"instant1\",\"ph\":\"i\","));
- CPPUNIT_ASSERT(aEvents[1].startsWith("{\"name\":\"async2.5\",\"ph\":\"b\",\"id\":1,"));
+ CPPUNIT_ASSERT(aEvents[1].startsWith("{\"name\":\"async2.5\",\"ph\":\"S\",\"id\":1,"));
CPPUNIT_ASSERT(aEvents[2].startsWith("{\"name\":\"block2\",\"ph\":\"X\","));
CPPUNIT_ASSERT(aEvents[3].startsWith(
- "{\"name\":\"async3\",\"ph\":\"b\",\"id\":2,\"args\":{\"foo\":\"bar\",\"tem\":\"42\"},"));
- CPPUNIT_ASSERT(aEvents[4].startsWith("{\"name\":\"async4in3\",\"ph\":\"b\",\"id\":2,"));
- CPPUNIT_ASSERT(aEvents[5].startsWith("{\"name\":\"block3\",\"ph\":\"X\","));
- CPPUNIT_ASSERT(aEvents[6].startsWith("{\"name\":\"async2.5\",\"ph\":\"e\",\"id\":1,"));
- CPPUNIT_ASSERT(aEvents[7].startsWith(
+ "{\"name\":\"async3\",\"ph\":\"S\",\"id\":2,\"args\":{\"foo\":\"bar\",\"tem\":\"42\"},"));
+ CPPUNIT_ASSERT(aEvents[4].startsWith("{\"name\":\"block3\",\"ph\":\"X\","));
+ CPPUNIT_ASSERT(aEvents[5].startsWith("{\"name\":\"async2.5\",\"ph\":\"F\",\"id\":1,"));
+ CPPUNIT_ASSERT(aEvents[6].startsWith(
"{\"name:\"instant2\",\"ph\":\"i\",\"args\":{\"foo2\":\"bar2\",\"tem2\":\"42\"},"));
- CPPUNIT_ASSERT(aEvents[8].startsWith("{\"name\":\"async5in4\",\"ph\":\"b\",\"id\":2,"));
- CPPUNIT_ASSERT(aEvents[9].startsWith("{\"name\":\"async6in5\",\"ph\":\"b\",\"id\":2,"));
- CPPUNIT_ASSERT(aEvents[10].startsWith("{\"name\":\"async6in5\",\"ph\":\"e\",\"id\":2,"));
- CPPUNIT_ASSERT(aEvents[11].startsWith("{\"name\":\"async5in4\",\"ph\":\"e\",\"id\":2,"));
- CPPUNIT_ASSERT(aEvents[12].startsWith("{\"name\":\"async7in3\",\"ph\":\"b\",\"id\":2,"));
- CPPUNIT_ASSERT(aEvents[13].startsWith("{\"name\":\"test2\",\"ph\":\"X\""));
- CPPUNIT_ASSERT(aEvents[14].startsWith("{\"name\":\"async4in3\",\"ph\":\"e\",\"id\":2,"));
- CPPUNIT_ASSERT(aEvents[15].startsWith("{\"name\":\"async7in3\",\"ph\":\"e\",\"id\":2,"));
- CPPUNIT_ASSERT(aEvents[16].startsWith(
- "{\"name\":\"async3\",\"ph\":\"e\",\"id\":2,\"args\":{\"foo\":\"bar\",\"tem\":\"42\"},"));
+ CPPUNIT_ASSERT(aEvents[7].startsWith("{\"name\":\"test2\",\"ph\":\"X\""));
+ CPPUNIT_ASSERT(aEvents[8].startsWith(
+ "{\"name\":\"async3\",\"ph\":\"F\",\"id\":2,\"args\":{\"foo\":\"bar\",\"tem\":\"42\"},"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(TestTraceEvent);