1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
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
23 class COMPHELPER_DLLPUBLIC ProfileZone
: public NamedEvent
25 long long m_nCreateTime
;
30 static void setNestingLevel(int nNestingLevel
);
31 static int getNestingLevel();
33 ProfileZone(const char* sName
, const OUString
& sArgs
)
34 : NamedEvent(sName
, sArgs
)
39 m_nCreateTime
= getNow();
41 m_nNesting
= getNestingLevel();
42 setNestingLevel(getNestingLevel() + 1);
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
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())
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
);
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: */