summaryrefslogtreecommitdiffstats
path: root/include/comphelper
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2021-04-15 14:31:40 +0300
committerTor Lillqvist <tml@collabora.com>2021-04-23 17:16:01 +0200
commit697de421f7983261726d497ec40d0ff1da791b57 (patch)
treefb093b545692b5df78b0c6c21d6d622dbbcf5167 /include/comphelper
parenthandle properly missing URI components for webdav/serf (diff)
downloadcore-697de421f7983261726d497ec40d0ff1da791b57.tar.gz
core-697de421f7983261726d497ec40d0ff1da791b57.zip
Refactor ProfileZone and create Chrome Trace Event Format data
Instead of separate B ("begin") and E ("end") duration events, generate X ("complete") events. Only the event JSON objects are generated, not the surrounding array or object. See https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview#heading=h.lc5airzennvk Online now needs work so that the events are written out to a separate file instead of being in the common log file. Change-Id: Ie9363b4cfda862a70e1928ed16350e50a6fee9a5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114142 Tested-by: Tor Lillqvist <tml@collabora.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114556 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'include/comphelper')
-rw-r--r--include/comphelper/profilezone.hxx55
1 files changed, 36 insertions, 19 deletions
diff --git a/include/comphelper/profilezone.hxx b/include/comphelper/profilezone.hxx
index 0c0df2089c98..9e05e8806e8e 100644
--- a/include/comphelper/profilezone.hxx
+++ b/include/comphelper/profilezone.hxx
@@ -14,6 +14,8 @@
#include <atomic>
+#include <osl/process.h>
+#include <osl/time.h>
#include <com/sun/star/uno/Sequence.h>
#include <comphelper/comphelperdllapi.h>
#include <rtl/ustring.hxx>
@@ -22,28 +24,21 @@
namespace comphelper
{
-namespace ProfileRecording
-{
-COMPHELPER_DLLPUBLIC void startRecording();
-COMPHELPER_DLLPUBLIC void stopRecording();
-
-COMPHELPER_DLLPUBLIC long long addRecording(const char* aProfileId, long long aCreateTime);
-
-COMPHELPER_DLLPUBLIC css::uno::Sequence<OUString> getRecordingAndClear();
-
-} // namespace ProfileRecording
-
class COMPHELPER_DLLPUBLIC ProfileZone
{
private:
- const char* m_sProfileId;
- long long m_aCreateTime;
+ static std::atomic<bool> s_bRecording; // true during recording
+ static int s_nNesting;
+ const char *m_sProfileId;
+ long long m_nCreateTime;
bool m_bConsole;
void startConsole();
void stopConsole();
+ int m_nPid;
+
+ void addRecording();
-public:
- static std::atomic<bool> g_bRecording; // true during recording
+ public:
/**
* Starts measuring the cost of a C++ scope.
@@ -61,10 +56,24 @@ public:
* committing.
*/
ProfileZone(const char* sProfileId, bool bConsole = false)
- : m_sProfileId(sProfileId)
- , m_aCreateTime(g_bRecording ? ProfileRecording::addRecording(sProfileId, 0) : 0)
+ : m_sProfileId(sProfileId ? sProfileId : "(null)")
, m_bConsole(bConsole)
{
+ if (s_bRecording)
+ {
+ TimeValue systemTime;
+ osl_getSystemTime( &systemTime );
+ m_nCreateTime = static_cast<long long>(systemTime.Seconds) * 1000000 + systemTime.Nanosec/1000;
+
+ oslProcessInfo aProcessInfo;
+ aProcessInfo.Size = sizeof(oslProcessInfo);
+ if (osl_getProcessInfo(nullptr, osl_Process_IDENTIFIER, &aProcessInfo) == osl_Process_E_None)
+ m_nPid = aProcessInfo.Ident;
+
+ s_nNesting++;
+ }
+ else
+ m_nCreateTime = 0;
if (m_bConsole)
{
startConsole();
@@ -72,13 +81,21 @@ public:
}
~ProfileZone()
{
- if (g_bRecording)
- ProfileRecording::addRecording(m_sProfileId, m_aCreateTime);
+ if (s_bRecording)
+ {
+ s_nNesting--;
+ addRecording();
+ }
if (m_bConsole)
{
stopConsole();
}
}
+
+ static void startRecording();
+ static void stopRecording();
+
+ static css::uno::Sequence<OUString> getRecordingAndClear();
};
} // namespace comphelper