summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-11-06 10:57:09 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-06 14:25:09 +0100
commitee9ccdf6ecd944c2f448a30d10700754d1f0cfa2 (patch)
treed9a9877a178229488df17ac7a3fca8e22135ed67 /include
parentdc80d60dc8dab1a124e2f4b33618b3a40cb1cbfa (diff)
reduce cost of ProfileZone when it is not active
by avoiding taking the mutex Also reduce the code that the mutex covers to the minimum necessary. Change-Id: I115c8a447ec17f4800c39557e8de0bc8c669b47b Reviewed-on: https://gerrit.libreoffice.org/62936 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include')
-rw-r--r--include/comphelper/profilezone.hxx13
1 files changed, 11 insertions, 2 deletions
diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx
index 3b3b5ee5041c..9def6f994fba 100644
--- a/include/comphelper/profilezone.hxx
+++ b/include/comphelper/profilezone.hxx
@@ -36,12 +36,21 @@ private:
const char * m_sProfileId;
long long const m_aCreateTime;
public:
+ static volatile bool g_bRecording; // true during recording
// Note that the char pointer is stored as such in the ProfileZone object and used in the
// destructor, so be sure to pass a pointer that stays valid for the duration of the object's
// lifetime.
- ProfileZone(const char * sProfileId);
- ~ProfileZone();
+ ProfileZone(const char *sProfileId)
+ : m_sProfileId(sProfileId),
+ m_aCreateTime(g_bRecording ? ProfileRecording::addRecording(sProfileId, 0) : 0)
+ {
+ }
+ ~ProfileZone()
+ {
+ if (g_bRecording)
+ ProfileRecording::addRecording(m_sProfileId, m_aCreateTime);
+ }
};
} // namespace comphelper