]>
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
6 // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
14 // This class is used to check that the arguments of log functions are not
18 NotCreated() { wxAbort(); }
20 const char* AsStr() const { return "unreachable"; }
23 // Temporarily change the log level to the given one.
27 LogLevelSetter(wxLogLevel levelNew
)
28 : m_levelOld(wxLog::GetLogLevel())
30 wxLog::SetLogLevel(levelNew
);
35 wxLog::SetLogLevel(m_levelOld
);
39 const wxLogLevel m_levelOld
;
41 wxDECLARE_NO_COPY_CLASS(LogLevelSetter
);
44 BENCHMARK_FUNC(LogDebugDisabled
)
46 LogLevelSetter
level(wxLOG_Info
);
48 wxLogDebug("Ignored debug message: %s", NotCreated().AsStr());
53 BENCHMARK_FUNC(LogTraceDisabled
)
55 LogLevelSetter
level(wxLOG_Info
);
57 wxLogTrace("", NotCreated().AsStr());
62 BENCHMARK_FUNC(LogTraceActive
)
64 static bool s_added
= false;
68 wxLog::AddTraceMask("logbench");
71 // Remove the actual logging overhead by simply throwing away the log
73 class NulLog
: public wxLog
77 : m_logOld(wxLog::SetActiveTarget(this))
83 wxLog::SetActiveTarget(m_logOld
);
87 virtual void DoLogRecord(wxLogLevel
,
89 const wxLogRecordInfo
&)
98 wxLogTrace("logbench", "Trace message");
103 BENCHMARK_FUNC(LogTraceInactive
)
105 wxLogTrace("bloordyblop", "Trace message");