]>
git.saurik.com Git - wxWidgets.git/blob - tests/benchmarks/log.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: tests/benchmarks/log.cpp
3 // Purpose: Log-related benchmarks
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
15 // This class is used to check that the arguments of log functions are not
19 NotCreated() { wxAbort(); }
21 const char* AsStr() const { return "unreachable"; }
24 // Temporarily change the log level to the given one.
28 LogLevelSetter(wxLogLevel levelNew
)
29 : m_levelOld(wxLog::GetLogLevel())
31 wxLog::SetLogLevel(levelNew
);
36 wxLog::SetLogLevel(m_levelOld
);
40 const wxLogLevel m_levelOld
;
42 wxDECLARE_NO_COPY_CLASS(LogLevelSetter
);
45 BENCHMARK_FUNC(LogDebugDisabled
)
47 LogLevelSetter
level(wxLOG_Info
);
49 wxLogDebug("Ignored debug message: %s", NotCreated().AsStr());
54 BENCHMARK_FUNC(LogTraceDisabled
)
56 LogLevelSetter
level(wxLOG_Info
);
58 wxLogTrace("", NotCreated().AsStr());
63 BENCHMARK_FUNC(LogTraceActive
)
65 static bool s_added
= false;
69 wxLog::AddTraceMask("logbench");
72 // Remove the actual logging overhead by simply throwing away the log
74 class NulLog
: public wxLog
78 : m_logOld(wxLog::SetActiveTarget(this))
84 wxLog::SetActiveTarget(m_logOld
);
88 virtual void DoLogRecord(wxLogLevel
,
90 const wxLogRecordInfo
&)
99 wxLogTrace("logbench", "Trace message");
104 BENCHMARK_FUNC(LogTraceInactive
)
106 wxLogTrace("bloordyblop", "Trace message");