desktop/source/lib/init.cxx | 64 +++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 27 deletions(-)
New commits: commit e4f5705b91ecacdfc84e564e116dfe812fd96b61 Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Mon May 10 15:50:45 2021 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Wed Jun 9 13:44:01 2021 +0200 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 <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tor Lillqvist <t...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115593 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116846 Tested-by: Jenkins 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"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits