[Libreoffice-commits] core.git: 2 commits - comphelper/source include/comphelper
Tor Lillqvist (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 28 14:33:28 UTC 2021
comphelper/source/misc/traceevent.cxx | 5 +----
include/comphelper/profilezone.hxx | 26 +++++++++++++-------------
include/comphelper/traceevent.hxx | 1 -
3 files changed, 14 insertions(+), 18 deletions(-)
New commits:
commit 969ddb6899b453194001e6743cc4d8003d5b050a
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Apr 27 13:32:19 2021 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Apr 28 16:32:28 2021 +0200
Re-think what the nesting means in ProfileZones
The "Complete" type of Trace Events should be properly nested. Use the
nesting counter to verify that. Add a nesting level indication to the
ProfileZone object. Assert that it is used properly.
Change-Id: I3a1f0e55ea6054dab9baf8550097446f07b0fbf3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114735
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml at collabora.com>
diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx
index 325ba59b131d..2cd2db829169 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -24,7 +24,7 @@ namespace comphelper
{
std::atomic<bool> TraceEvent::s_bRecording = false;
-int TraceEvent::s_nNesting = 0; // level of overlapped zones
+int ProfileZone::s_nNesting = 0;
namespace
{
@@ -70,7 +70,6 @@ void TraceEvent::addInstantEvent(const char* sProfileId)
void TraceEvent::startRecording()
{
::osl::MutexGuard aGuard(g_aMutex);
- s_nNesting = 0;
s_bRecording = true;
}
diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx
index 32dc02e14f74..dec5b35928bc 100644
--- a/include/comphelper/profilezone.hxx
+++ b/include/comphelper/profilezone.hxx
@@ -20,11 +20,14 @@ namespace comphelper
{
class COMPHELPER_DLLPUBLIC ProfileZone : public TraceEvent
{
+ static int s_nNesting; // level of nested zones.
+
const char* m_sProfileId;
long long m_nCreateTime;
bool m_bConsole;
void stopConsole();
int m_nPid;
+ int m_nNesting;
void addRecording();
@@ -54,32 +57,31 @@ public:
osl_getSystemTime(&systemTime);
m_nCreateTime
= static_cast<long long>(systemTime.Seconds) * 1000000 + systemTime.Nanosec / 1000;
- }
- else
- m_nCreateTime = 0;
- if (s_bRecording)
- {
oslProcessInfo aProcessInfo;
aProcessInfo.Size = sizeof(oslProcessInfo);
if (osl_getProcessInfo(nullptr, osl_Process_IDENTIFIER, &aProcessInfo)
== osl_Process_E_None)
m_nPid = aProcessInfo.Ident;
- s_nNesting++;
+ m_nNesting = s_nNesting++;
}
+ else
+ m_nCreateTime = 0;
}
~ProfileZone()
{
- if (s_bRecording)
+ if (m_nCreateTime > 0)
{
s_nNesting--;
- addRecording();
- }
- if (m_bConsole)
- {
- stopConsole();
+ assert(m_nNesting == s_nNesting);
+
+ if (s_bRecording)
+ addRecording();
+
+ if (m_bConsole)
+ stopConsole();
}
}
diff --git a/include/comphelper/traceevent.hxx b/include/comphelper/traceevent.hxx
index 14e25da9b791..ff66a834e639 100644
--- a/include/comphelper/traceevent.hxx
+++ b/include/comphelper/traceevent.hxx
@@ -28,7 +28,6 @@ class COMPHELPER_DLLPUBLIC TraceEvent
{
protected:
static std::atomic<bool> s_bRecording; // true during recording
- static int s_nNesting;
static void addRecording(const OUString& sObject);
commit d57ac8ff9c0b4ec8706d1d64c4a0ee9eb23de66c
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Apr 27 11:14:07 2021 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Apr 28 16:31:56 2021 +0200
Make the console logging in ProfileZone work more sanely
Do not re-assing a value to the m_nCreateTime if bConsole is true.
Just use the same code that sets it in the constructor as in the case
when recording is on.
Change-Id: I1ca3c5aa00e2f8f0faa7ca3433e1eb066413c2a2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114734
Tested-by: Tor Lillqvist <tml at collabora.com>
Reviewed-by: Tor Lillqvist <tml at collabora.com>
diff --git a/comphelper/source/misc/traceevent.cxx b/comphelper/source/misc/traceevent.cxx
index 6e86c3f03993..325ba59b131d 100644
--- a/comphelper/source/misc/traceevent.cxx
+++ b/comphelper/source/misc/traceevent.cxx
@@ -120,8 +120,6 @@ void ProfileZone::addRecording()
+ OUString::number(osl_getThreadIdentifier(nullptr)) + "},");
}
-void ProfileZone::startConsole() { m_nCreateTime = osl_getGlobalTimer(); }
-
void ProfileZone::stopConsole()
{
sal_uInt32 nEndTime = osl_getGlobalTimer();
diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx
index 4bdd6ad53fb5..32dc02e14f74 100644
--- a/include/comphelper/profilezone.hxx
+++ b/include/comphelper/profilezone.hxx
@@ -23,7 +23,6 @@ class COMPHELPER_DLLPUBLIC ProfileZone : public TraceEvent
const char* m_sProfileId;
long long m_nCreateTime;
bool m_bConsole;
- void startConsole();
void stopConsole();
int m_nPid;
@@ -49,13 +48,18 @@ public:
: m_sProfileId(sProfileId ? sProfileId : "(null)")
, m_bConsole(bConsole)
{
- if (s_bRecording)
+ if (s_bRecording || m_bConsole)
{
TimeValue systemTime;
osl_getSystemTime(&systemTime);
m_nCreateTime
= static_cast<long long>(systemTime.Seconds) * 1000000 + systemTime.Nanosec / 1000;
+ }
+ else
+ m_nCreateTime = 0;
+ if (s_bRecording)
+ {
oslProcessInfo aProcessInfo;
aProcessInfo.Size = sizeof(oslProcessInfo);
if (osl_getProcessInfo(nullptr, osl_Process_IDENTIFIER, &aProcessInfo)
@@ -64,12 +68,6 @@ public:
s_nNesting++;
}
- else
- m_nCreateTime = 0;
- if (m_bConsole)
- {
- startConsole();
- }
}
~ProfileZone()
More information about the Libreoffice-commits
mailing list