diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-03-03 21:01:58 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-03-04 09:04:14 +0100 |
commit | c57d6d39c80844c9d4c6bfed85cc151e52a67b34 (patch) | |
tree | ed0c2f7b7071040f5d0f87dff1222151479e7029 /include | |
parent | 3d38514166b2e3090e03d16df11e83e184eee433 (diff) |
comphelper: allow simple ad-hoc measuring with ProfileZones
And then remove the manual measuring from the RTF import.
Sample output:
comphelper::ProfileZone: RtfFilter::filter finished in 180 ms
Change-Id: I85e2e12d82ff491a2991a41e5a6f6d1410e12363
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89905
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/comphelper/profilezone.hxx | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx index 8cbc078f6621..81294a4c41c6 100644 --- a/include/comphelper/profilezone.hxx +++ b/include/comphelper/profilezone.hxx @@ -38,22 +38,46 @@ class COMPHELPER_DLLPUBLIC ProfileZone { private: const char * m_sProfileId; - long long const m_aCreateTime; + long long m_aCreateTime; + bool m_bConsole; + void startConsole(); + void stopConsole(); public: static std::atomic<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) + /** + * Starts measuring the cost of a C++ scope. + * + * 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. + * + * The second parameter can be used for ad-hoc local measuring by adding a single line of code + * at a C++ scope start. Example: + * + * comphelper::ProfileZone aZone("RtfFilter::filter", true); + * + * Similar to the DEBUG macro in sal/log.hxx, don't forget to remove these lines before + * committing. + */ + ProfileZone(const char *sProfileId, bool bConsole = false) : m_sProfileId(sProfileId), - m_aCreateTime(g_bRecording ? ProfileRecording::addRecording(sProfileId, 0) : 0) + m_aCreateTime(g_bRecording ? ProfileRecording::addRecording(sProfileId, 0) : 0), + m_bConsole(bConsole) { + if (m_bConsole) + { + startConsole(); + } } ~ProfileZone() { if (g_bRecording) ProfileRecording::addRecording(m_sProfileId, m_aCreateTime); + if (m_bConsole) + { + stopConsole(); + } } }; |