summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-05-11 13:58:38 +0300
committerTor Lillqvist <tml@collabora.com>2021-05-18 10:50:08 +0200
commit5db487e0c03eccd7a8d0901bf0eca3e45ed5a723 (patch)
tree6e9cc6f166a623a22b768fcb3cca13b281a85ee8 /comphelper
parentc3b9503ab2c09534c954c64e8e0794b0d15661d6 (diff)
Add the possibility to include a set of arguments in Trace Events
Change-Id: I55720baf64bd9b719026c94e4373b6368a1a7106 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115396 Tested-by: Tor Lillqvist <tml@collabora.com> Reviewed-by: Tor Lillqvist <tml@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115594 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/qa/unit/test_traceevent.cxx15
-rw-r--r--comphelper/source/misc/traceevent.cxx9
2 files changed, 14 insertions, 10 deletions
diff --git a/comphelper/qa/unit/test_traceevent.cxx b/comphelper/qa/unit/test_traceevent.cxx
index 29094b14f01b..dc61b92cde77 100644
--- a/comphelper/qa/unit/test_traceevent.cxx
+++ b/comphelper/qa/unit/test_traceevent.cxx
@@ -74,7 +74,8 @@ void trace_event_test()
CPPUNIT_ASSERT(pAsync2.expired());
// This will generate a 'b' event for async3
- auto pAsync3(std::make_shared<comphelper::AsyncEvent>("async3"));
+ auto pAsync3(std::make_shared<comphelper::AsyncEvent>(
+ "async3", std::map<OUString, OUString>({ { "foo", "bar" }, { "tem", "42" } })));
std::weak_ptr<comphelper::AsyncEvent> pAsync4;
@@ -92,7 +93,8 @@ void trace_event_test()
comphelper::ProfileZone aZone4("test2");
// This will generate an 'i' event for instant2"
- comphelper::TraceEvent::addInstantEvent("instant2");
+ comphelper::TraceEvent::addInstantEvent(
+ "instant2", std::map<OUString, OUString>({ { "foo2", "bar2" }, { "tem2", "42" } }));
std::weak_ptr<comphelper::AsyncEvent> pAsync5;
{
@@ -148,11 +150,13 @@ void TestTraceEvent::test()
CPPUNIT_ASSERT(aEvents[0].startsWith("{\"name:\"instant1\",\"ph\":\"i\","));
CPPUNIT_ASSERT(aEvents[1].startsWith("{\"name\":\"async2.5\",\"ph\":\"b\",\"id\":1,"));
CPPUNIT_ASSERT(aEvents[2].startsWith("{\"name\":\"block2\",\"ph\":\"X\","));
- CPPUNIT_ASSERT(aEvents[3].startsWith("{\"name\":\"async3\",\"ph\":\"b\",\"id\":2,"));
+ 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:\"instant2\",\"ph\":\"i\","));
+ CPPUNIT_ASSERT(aEvents[7].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,"));
@@ -161,7 +165,8 @@ void TestTraceEvent::test()
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,"));
+ CPPUNIT_ASSERT(aEvents[16].startsWith(
+ "{\"name\":\"async3\",\"ph\":\"e\",\"id\":2,\"args\":{\"foo\",\"bar\",\"tem\",\"42\"},"));
}
CPPUNIT_TEST_SUITE_REGISTRATION(TestTraceEvent);
diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx
index 81039c9ca82d..5f0ddcc18d39 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -40,7 +40,7 @@ void TraceEvent::addRecording(const OUString& sObject)
g_aRecording.emplace_back(sObject);
}
-void TraceEvent::addInstantEvent(const char* sName)
+void TraceEvent::addInstantEvent(const char* sName, const std::map<OUString, OUString>& args)
{
long long nNow = getNow();
@@ -54,9 +54,8 @@ void TraceEvent::addInstantEvent(const char* sName)
"\"name:\""
+ OUString(sName, strlen(sName), RTL_TEXTENCODING_UTF8)
+ "\","
- "\"ph\":\"i\","
- "\"ts\":"
- + OUString::number(nNow)
+ "\"ph\":\"i\""
+ + createArgsString(args) + ",\"ts\":" + OUString::number(nNow)
+ ","
"\"pid\":"
+ OUString::number(nPid)
@@ -110,7 +109,7 @@ void ProfileZone::addRecording()
+ OUString::number(m_nCreateTime)
+ ","
"\"dur\":"
- + OUString::number(nNow - m_nCreateTime)
+ + OUString::number(nNow - m_nCreateTime) + m_sArgs
+ ","
"\"pid\":"
+ OUString::number(m_nPid)