forked from qt-creator/qt-creator
Process: Read QTC_MEASURE_PROCESS just once
And store it in static variable. Change-Id: Ia630f63125088bff32a4d6df9de4c8279c8d8b34 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -58,17 +58,22 @@ static bool isGuiEnabled()
|
|||||||
return isGuiApp && isMainThread();
|
return isGuiApp && isMainThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isMeasuring()
|
||||||
|
{
|
||||||
|
static const bool measuring = qtcEnvironmentVariableIsSet("QTC_MEASURE_PROCESS");
|
||||||
|
return measuring;
|
||||||
|
}
|
||||||
|
|
||||||
class MeasureAndRun
|
class MeasureAndRun
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MeasureAndRun(const char *functionName)
|
MeasureAndRun(const char *functionName)
|
||||||
: m_functionName(functionName)
|
: m_functionName(functionName)
|
||||||
, m_measureProcess(qtcEnvironmentVariableIsSet("QTC_MEASURE_PROCESS"))
|
|
||||||
{}
|
{}
|
||||||
template <typename Function, typename... Args>
|
template <typename Function, typename... Args>
|
||||||
std::invoke_result_t<Function, Args...> measureAndRun(Function &&function, Args&&... args)
|
std::invoke_result_t<Function, Args...> measureAndRun(Function &&function, Args&&... args)
|
||||||
{
|
{
|
||||||
if (!m_measureProcess)
|
if (!isMeasuring())
|
||||||
return std::invoke(std::forward<Function>(function), std::forward<Args>(args)...);
|
return std::invoke(std::forward<Function>(function), std::forward<Args>(args)...);
|
||||||
QElapsedTimer timer;
|
QElapsedTimer timer;
|
||||||
timer.start();
|
timer.start();
|
||||||
@@ -151,7 +156,6 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char * const m_functionName;
|
const char * const m_functionName;
|
||||||
const bool m_measureProcess;
|
|
||||||
std::atomic_int m_hitThisAll = 0;
|
std::atomic_int m_hitThisAll = 0;
|
||||||
std::atomic_int m_hitThisMain = 0;
|
std::atomic_int m_hitThisMain = 0;
|
||||||
std::atomic_int64_t m_totalThisAll = 0;
|
std::atomic_int64_t m_totalThisAll = 0;
|
||||||
|
Reference in New Issue
Block a user