diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-06-23 13:05:36 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2021-06-23 13:34:50 +0200 |
commit | 90df123cd9ff9fc1c7b991d9ae9a1ed8c9e9f0de (patch) | |
tree | dcc70aae205d237da3d7ef11c4b9dd32803481de /comphelper/qa/unit | |
parent | 63cd67e5e18f01aca303131e148c80398a181a41 (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>
Diffstat (limited to 'comphelper/qa/unit')
-rw-r--r-- | comphelper/qa/unit/test_traceevent.cxx | 67 |
1 files changed, 10 insertions, 57 deletions
diff --git a/comphelper/qa/unit/test_traceevent.cxx b/comphelper/qa/unit/test_traceevent.cxx index b6be38f02ca8..46c1cef5be25 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 std::map<OUString, OUString> aArgsAsync3({ { "foo", "bar" }, { "tem", "42" } }); auto pAsync3(std::make_shared<comphelper::AsyncEvent>("async3", aArgsAsync3)); - 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() std::map<OUString, OUString> aArgsInstant2({ { "foo2", "bar2" }, { "tem2", "42" } }); comphelper::TraceEvent::addInstantEvent("instant2", aArgsInstant2); - 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); |