desktop/source/lib/init.cxx | 62 +++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 26 deletions(-)
New commits: commit c3b9503ab2c09534c954c64e8e0794b0d15661d6 Author: Tor Lillqvist <[email protected]> AuthorDate: Mon May 10 15:50:45 2021 +0300 Commit: Tor Lillqvist <[email protected]> CommitDate: Tue May 18 10:08:08 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 <[email protected]> Reviewed-by: Tor Lillqvist <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115593 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 764b10743c11..6fdf245c4495 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -202,6 +202,37 @@ struct ExtensionMap } +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); + } + } +}; + +static TraceEventDumper *traceEventDumper = nullptr; + const ExtensionMap aWriterExtensionMap[] = { { "doc", "MS Word 97" }, @@ -3854,7 +3885,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(); } @@ -6102,31 +6137,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(const OUString& rApp) { OUString aPath = "org.openoffice.Office.UI.ToolbarMode/Applications/" + rApp; @@ -6197,7 +6207,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 [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
