diff options
author | Tor Lillqvist <tml@collabora.com> | 2021-05-10 15:50:45 +0300 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2021-06-09 13:44:01 +0200 |
commit | e4f5705b91ecacdfc84e564e116dfe812fd96b61 (patch) | |
tree | 83073d395a9d3ba5f3ad8f612a35fc06bcd27e08 /desktop | |
parent | 1c01bdd6c1fabf301218560d7d1d26dea6915827 (diff) |
We must collect the Trace Events when recording them is turned on
Recording them can be turned on and off on-the-fly.
Also rename the class from ProfileZoneDumper to TraceEventDumper as
ProfileZones are just one special case of Trace Events.
Change-Id: I4928397937963c83ffe8022ba4fa941f81119e15
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115332
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Tor Lillqvist <tml@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115593
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116846
Tested-by: Jenkins
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 77fb9e4baecc..d509643ce4d1 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -200,7 +200,38 @@ struct ExtensionMap const char *filterName; }; -} +class TraceEventDumper : public AutoTimer +{ + static const int dumpTimeoutMS = 5000; + +public: + TraceEventDumper() : AutoTimer( "Trace Event dumper" ) + { + SetTimeout(dumpTimeoutMS); + Start(); + } + virtual void Invoke() override + { + const css::uno::Sequence<OUString> aEvents = + comphelper::TraceEvent::getRecordingAndClear(); + OStringBuffer aOutput; + for (const auto &s : aEvents) + { + aOutput.append(OUStringToOString(s, RTL_TEXTENCODING_UTF8)); + aOutput.append("\n"); + } + if (aOutput.getLength() > 0) + { + OString aChunk = aOutput.makeStringAndClear(); + if (gImpl && gImpl->mpCallback) + gImpl->mpCallback(LOK_CALLBACK_PROFILE_FRAME, aChunk.getStr(), gImpl->mpCallbackData); + } + } +}; + +} // unnamed namespace + +static TraceEventDumper *traceEventDumper = nullptr; const ExtensionMap aWriterExtensionMap[] = { @@ -3852,7 +3883,11 @@ static void lo_setOption(LibreOfficeKit* /*pThis*/, const char *pOption, const c if (strcmp(pOption, "traceeventrecording") == 0) { if (strcmp(pValue, "start") == 0) + { comphelper::TraceEvent::startRecording(); + if (traceEventDumper == nullptr) + traceEventDumper = new TraceEventDumper(); + } else if (strcmp(pValue, "stop") == 0) comphelper::TraceEvent::stopRecording(); } @@ -6095,31 +6130,6 @@ static void preloadData() namespace { -class ProfileZoneDumper : public AutoTimer -{ - static const int dumpTimeoutMS = 5000; -public: - ProfileZoneDumper() : AutoTimer( "zone dumper" ) - { - SetTimeout(dumpTimeoutMS); - Start(); - } - virtual void Invoke() override - { - const css::uno::Sequence<OUString> aEvents = - comphelper::TraceEvent::getRecordingAndClear(); - OStringBuffer aOutput; - for (const auto &s : aEvents) - { - aOutput.append(OUStringToOString(s, RTL_TEXTENCODING_UTF8)); - aOutput.append("\n"); - } - OString aChunk = aOutput.makeStringAndClear(); - if (gImpl && gImpl->mpCallback) - gImpl->mpCallback(LOK_CALLBACK_PROFILE_FRAME, aChunk.getStr(), gImpl->mpCallbackData); - } -}; - static void activateNotebookbar(std::u16string_view rApp) { OUString aPath = OUString::Concat("org.openoffice.Office.UI.ToolbarMode/Applications/") + rApp; @@ -6190,7 +6200,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char if (bProfileZones && eStage == SECOND_INIT) { comphelper::TraceEvent::startRecording(); - new ProfileZoneDumper(); + traceEventDumper = new TraceEventDumper(); } comphelper::ProfileZone aZone("lok-init"); |