android: Update app-specific/MIME type icons
[LibreOffice.git] / include / comphelper / profilezone.hxx
blob71f9fa30b6dcdb44df2fd040def9a45b4ff6df76
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.
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 */
10 #ifndef INCLUDED_COMPHELPER_PROFILEZONE_HXX
11 #define INCLUDED_COMPHELPER_PROFILEZONE_HXX
13 #include <sal/config.h>
15 #include <sal/log.hxx>
17 #include <comphelper/traceevent.hxx>
19 // implementation of XToolkitExperimental profiling API
21 namespace comphelper
23 class COMPHELPER_DLLPUBLIC ProfileZone : public NamedEvent
25 long long m_nCreateTime;
26 int m_nNesting;
28 void addRecording();
30 static void setNestingLevel(int nNestingLevel);
31 static int getNestingLevel();
33 ProfileZone(const char* sName, const OUString& sArgs)
34 : NamedEvent(sName, sArgs)
35 , m_nNesting(-1)
37 if (s_bRecording)
39 m_nCreateTime = getNow();
41 m_nNesting = getNestingLevel();
42 setNestingLevel(getNestingLevel() + 1);
44 else
45 m_nCreateTime = 0;
48 public:
49 /**
50 * Starts measuring the cost of a C++ scope.
52 * Note that the char pointer is stored as such in the ProfileZone object and used in the
53 * destructor, so be sure to pass a pointer that stays valid for the duration of the object's
54 * lifetime.
56 ProfileZone(const char* sName, const std::map<OUString, OUString>& aArgs)
57 : ProfileZone(sName, createArgsString(aArgs))
61 ProfileZone(const char* sName)
62 : ProfileZone(sName, OUString())
66 ~ProfileZone()
68 if (m_nCreateTime > 0)
70 setNestingLevel(getNestingLevel() - 1);
72 if (m_nNesting != getNestingLevel())
74 SAL_WARN("comphelper.traceevent", "Incorrect ProfileZone nesting for " << m_sName);
76 else
78 if (s_bRecording)
79 addRecording();
84 ProfileZone(const ProfileZone&) = delete;
85 void operator=(const ProfileZone&) = delete;
88 } // namespace comphelper
90 #endif // INCLUDED_COMPHELPER_PROFILEZONE_HXX
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */