14 #include <string_view>
19 #include <osl/thread.h>
24 std::atomic<bool> ProfileZone::g_bRecording(
false);
26 namespace ProfileRecording
40 osl_getSystemTime( &systemTime );
41 ::osl::MutexGuard aGuard( g_aMutex );
42 g_aStartTime =
static_cast<long long>(systemTime.Seconds) * 1000000 + systemTime.Nanosec/1000;
45 ProfileZone::g_bRecording = bStartRecording;
48 long long addRecording(
const char * aProfileId,
long long aCreateTime)
50 assert( ProfileZone::g_bRecording );
53 osl_getSystemTime( &systemTime );
54 long long aTime =
static_cast<long long>(systemTime.Seconds) * 1000000 + systemTime.Nanosec/1000;
57 aProfileId =
"(null)";
58 OUString aString(aProfileId, strlen(aProfileId), RTL_TEXTENCODING_UTF8);
60 OUString sRecordingData(OUString::number(osl_getThreadIdentifier(
nullptr)) +
" " +
61 OUString::number(aTime/1000000.0) +
" " + aString +
": " +
62 (aCreateTime == 0 ? std::u16string_view(
u"start") : std::u16string_view(
u"stop")) +
63 (aCreateTime != 0 ? (
" " + OUString::number((aTime - aCreateTime)/1000.0) +
" ms") : OUString(
"")));
65 ::osl::MutexGuard aGuard( g_aMutex );
67 g_aRecording.emplace_back(sRecordingData);
74 else if (aCreateTime >= g_aStartTime)
87 std::vector<OUString> aRecording;
89 ::osl::MutexGuard aGuard( g_aMutex );
90 bRecording = ProfileZone::g_bRecording;
92 aRecording.swap(g_aRecording);
94 aRecording.insert(aRecording.begin(), OUString::number(aSumTime/1000000.0));
103 void ProfileZone::startConsole() { m_aCreateTime = osl_getGlobalTimer(); }
105 void ProfileZone::stopConsole()
107 sal_uInt32 nEndTime = osl_getGlobalTimer();
108 std::cerr <<
"comphelper::ProfileZone: " << m_sProfileId <<
" finished in "
109 << nEndTime - m_aCreateTime <<
" ms" << std::endl;
static long long g_aSumTime(0)
css::uno::Sequence< OUString > getRecordingAndClear()
static long long g_aStartTime
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
static std::vector< OUString > g_aRecording
long long addRecording(const char *aProfileId, long long aCreateTime)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
Copy from a container into a Sequence.
void startRecording(bool bStartRecording)
if(!pCandidateA->getEnd().equal(pCandidateB->getStart()))