LibreOffice Module comphelper (master) 1
profilezone.hxx
Go to the documentation of this file.
1/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8*/
9
10#ifndef INCLUDED_COMPHELPER_PROFILEZONE_HXX
11#define INCLUDED_COMPHELPER_PROFILEZONE_HXX
12
13#include <sal/config.h>
14
15#include <sal/log.hxx>
16
18
19// implementation of XToolkitExperimental profiling API
20
21namespace comphelper
22{
23class COMPHELPER_DLLPUBLIC ProfileZone : public NamedEvent
24{
25 long long m_nCreateTime;
27
28 void addRecording();
29
30 static void setNestingLevel(int nNestingLevel);
31 static int getNestingLevel();
32
33 ProfileZone(const char* sName, const OUString& sArgs)
34 : NamedEvent(sName, sArgs)
35 , m_nNesting(-1)
36 {
37 if (s_bRecording)
38 {
39 m_nCreateTime = getNow();
40
41 m_nNesting = getNestingLevel();
42 setNestingLevel(getNestingLevel() + 1);
43 }
44 else
45 m_nCreateTime = 0;
46 }
47
48public:
56 ProfileZone(const char* sName, const std::map<OUString, OUString>& aArgs)
57 : ProfileZone(sName, createArgsString(aArgs))
58 {
59 }
60
61 ProfileZone(const char* sName)
62 : ProfileZone(sName, OUString())
63 {
64 }
65
67 {
68 if (m_nCreateTime > 0)
69 {
70 setNestingLevel(getNestingLevel() - 1);
71
72 if (m_nNesting != getNestingLevel())
73 {
74 SAL_WARN("comphelper.traceevent", "Incorrect ProfileZone nesting for " << m_sName);
75 }
76 else
77 {
78 if (s_bRecording)
79 addRecording();
80 }
81 }
82 }
83
84 ProfileZone(const ProfileZone&) = delete;
85 void operator=(const ProfileZone&) = delete;
86};
87
88} // namespace comphelper
89
90#endif // INCLUDED_COMPHELPER_PROFILEZONE_HXX
91
92/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ProfileZone(const char *sName, const OUString &sArgs)
Definition: profilezone.hxx:33
void operator=(const ProfileZone &)=delete
ProfileZone(const ProfileZone &)=delete
ProfileZone(const char *sName)
Definition: profilezone.hxx:61
ProfileZone(const char *sName, const std::map< OUString, OUString > &aArgs)
Starts measuring the cost of a C++ scope.
Definition: profilezone.hxx:56
#define COMPHELPER_DLLPUBLIC
OUString m_sName
OUString sName
#define SAL_WARN(area, stream)