diff --git a/tests/benchmarks/Makefile.in b/tests/benchmarks/Makefile.in
index d9f1f12267..faeb014d26 100644
--- a/tests/benchmarks/Makefile.in
+++ b/tests/benchmarks/Makefile.in
@@ -48,6 +48,7 @@ BENCH_OBJECTS = \
bench_htmlpars.o \
bench_htmltag.o \
bench_ipcclient.o \
+ bench_log.o \
bench_mbconv.o \
bench_strings.o \
bench_tls.o \
@@ -146,6 +147,9 @@ bench_htmltag.o: $(srcdir)/htmlparser/htmltag.cpp
bench_ipcclient.o: $(srcdir)/ipcclient.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/ipcclient.cpp
+bench_log.o: $(srcdir)/log.cpp
+ $(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/log.cpp
+
bench_mbconv.o: $(srcdir)/mbconv.cpp
$(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/mbconv.cpp
diff --git a/tests/benchmarks/bench.bkl b/tests/benchmarks/bench.bkl
index 452900a95f..818d38a655 100644
--- a/tests/benchmarks/bench.bkl
+++ b/tests/benchmarks/bench.bkl
@@ -15,6 +15,7 @@
htmlparser/htmlpars.cpp
htmlparser/htmltag.cpp
ipcclient.cpp
+ log.cpp
mbconv.cpp
strings.cpp
tls.cpp
diff --git a/tests/benchmarks/bench.dsp b/tests/benchmarks/bench.dsp
index f87807d078..04c167b026 100644
--- a/tests/benchmarks/bench.dsp
+++ b/tests/benchmarks/bench.dsp
@@ -255,6 +255,10 @@ SOURCE=.\ipcclient.cpp
# End Source File
# Begin Source File
+SOURCE=.\log.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\mbconv.cpp
# End Source File
# Begin Source File
diff --git a/tests/benchmarks/bench_vc7.vcproj b/tests/benchmarks/bench_vc7.vcproj
index 0968742ce1..ea5d18e4f2 100644
--- a/tests/benchmarks/bench_vc7.vcproj
+++ b/tests/benchmarks/bench_vc7.vcproj
@@ -556,6 +556,9 @@
+
+
diff --git a/tests/benchmarks/bench_vc8.vcproj b/tests/benchmarks/bench_vc8.vcproj
index d206538dc5..cd1d03a743 100644
--- a/tests/benchmarks/bench_vc8.vcproj
+++ b/tests/benchmarks/bench_vc8.vcproj
@@ -44,14 +44,14 @@
/>
@@ -141,14 +141,14 @@
/>
@@ -237,14 +237,14 @@
/>
@@ -334,14 +334,14 @@
/>
@@ -430,14 +430,14 @@
/>
@@ -527,14 +527,14 @@
/>
@@ -623,14 +623,14 @@
/>
@@ -720,14 +720,14 @@
/>
@@ -823,6 +823,10 @@
RelativePath=".\ipcclient.cpp"
>
+
+
diff --git a/tests/benchmarks/bench_vc9.vcproj b/tests/benchmarks/bench_vc9.vcproj
index 55726ee9c7..f4786b1dd4 100644
--- a/tests/benchmarks/bench_vc9.vcproj
+++ b/tests/benchmarks/bench_vc9.vcproj
@@ -44,7 +44,7 @@
/>
@@ -137,7 +137,7 @@
/>
@@ -230,7 +230,7 @@
/>
@@ -323,7 +323,7 @@
/>
@@ -416,7 +416,7 @@
/>
@@ -509,7 +509,7 @@
/>
@@ -602,7 +602,7 @@
/>
@@ -695,7 +695,7 @@
/>
@@ -795,6 +795,10 @@
RelativePath=".\ipcclient.cpp"
>
+
+
diff --git a/tests/benchmarks/log.cpp b/tests/benchmarks/log.cpp
new file mode 100644
index 0000000000..41e9c7ea15
--- /dev/null
+++ b/tests/benchmarks/log.cpp
@@ -0,0 +1,109 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: tests/benchmarks/log.cpp
+// Purpose: Log-related benchmarks
+// Author: Vadim Zeitlin
+// Created: 2012-01-21
+// RCS-ID: $Id$
+// Copyright: (c) 2011 Vadim Zeitlin
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#include "bench.h"
+
+#include "wx/log.h"
+
+// This class is used to check that the arguments of log functions are not
+// evaluated.
+struct NotCreated
+{
+ NotCreated() { wxAbort(); }
+
+ const char* AsStr() const { return "unreachable"; }
+};
+
+// Temporarily change the log level to the given one.
+class LogLevelSetter
+{
+public:
+ LogLevelSetter(wxLogLevel levelNew)
+ : m_levelOld(wxLog::GetLogLevel())
+ {
+ wxLog::SetLogLevel(levelNew);
+ }
+
+ ~LogLevelSetter()
+ {
+ wxLog::SetLogLevel(m_levelOld);
+ }
+
+private:
+ const wxLogLevel m_levelOld;
+
+ wxDECLARE_NO_COPY_CLASS(LogLevelSetter);
+};
+
+BENCHMARK_FUNC(LogDebugDisabled)
+{
+ LogLevelSetter level(wxLOG_Info);
+
+ wxLogDebug("Ignored debug message: %s", NotCreated().AsStr());
+
+ return true;
+}
+
+BENCHMARK_FUNC(LogTraceDisabled)
+{
+ LogLevelSetter level(wxLOG_Info);
+
+ wxLogTrace("", NotCreated().AsStr());
+
+ return true;
+}
+
+BENCHMARK_FUNC(LogTraceActive)
+{
+ static bool s_added = false;
+ if ( !s_added )
+ {
+ s_added = true;
+ wxLog::AddTraceMask("logbench");
+ }
+
+ // Remove the actual logging overhead by simply throwing away the log
+ // messages.
+ class NulLog : public wxLog
+ {
+ public:
+ NulLog()
+ : m_logOld(wxLog::SetActiveTarget(this))
+ {
+ }
+
+ virtual ~NulLog()
+ {
+ wxLog::SetActiveTarget(m_logOld);
+ }
+
+ protected:
+ virtual void DoLogRecord(wxLogLevel,
+ const wxString&,
+ const wxLogRecordInfo&)
+ {
+ }
+
+ wxLog* m_logOld;
+ };
+
+ NulLog nulLog;
+
+ wxLogTrace("logbench", "Trace message");
+
+ return true;
+}
+
+BENCHMARK_FUNC(LogTraceInactive)
+{
+ wxLogTrace("bloordyblop", "Trace message");
+
+ return true;
+}
diff --git a/tests/benchmarks/makefile.bcc b/tests/benchmarks/makefile.bcc
index 178196ffde..3eefc629d1 100644
--- a/tests/benchmarks/makefile.bcc
+++ b/tests/benchmarks/makefile.bcc
@@ -41,6 +41,7 @@ BENCH_OBJECTS = \
$(OBJS)\bench_htmlpars.obj \
$(OBJS)\bench_htmltag.obj \
$(OBJS)\bench_ipcclient.obj \
+ $(OBJS)\bench_log.obj \
$(OBJS)\bench_mbconv.obj \
$(OBJS)\bench_strings.obj \
$(OBJS)\bench_tls.obj \
@@ -225,6 +226,9 @@ $(OBJS)\bench_htmltag.obj: .\htmlparser\htmltag.cpp
$(OBJS)\bench_ipcclient.obj: .\ipcclient.cpp
$(CXX) -q -c -P -o$@ $(BENCH_CXXFLAGS) .\ipcclient.cpp
+$(OBJS)\bench_log.obj: .\log.cpp
+ $(CXX) -q -c -P -o$@ $(BENCH_CXXFLAGS) .\log.cpp
+
$(OBJS)\bench_mbconv.obj: .\mbconv.cpp
$(CXX) -q -c -P -o$@ $(BENCH_CXXFLAGS) .\mbconv.cpp
diff --git a/tests/benchmarks/makefile.gcc b/tests/benchmarks/makefile.gcc
index ec149b1548..2da8a4ed37 100644
--- a/tests/benchmarks/makefile.gcc
+++ b/tests/benchmarks/makefile.gcc
@@ -34,6 +34,7 @@ BENCH_OBJECTS = \
$(OBJS)\bench_htmlpars.o \
$(OBJS)\bench_htmltag.o \
$(OBJS)\bench_ipcclient.o \
+ $(OBJS)\bench_log.o \
$(OBJS)\bench_mbconv.o \
$(OBJS)\bench_strings.o \
$(OBJS)\bench_tls.o \
@@ -211,6 +212,9 @@ $(OBJS)\bench_htmltag.o: ./htmlparser/htmltag.cpp
$(OBJS)\bench_ipcclient.o: ./ipcclient.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\bench_log.o: ./log.cpp
+ $(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\bench_mbconv.o: ./mbconv.cpp
$(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $<
diff --git a/tests/benchmarks/makefile.vc b/tests/benchmarks/makefile.vc
index 8ca6031cc4..6a742ae88e 100644
--- a/tests/benchmarks/makefile.vc
+++ b/tests/benchmarks/makefile.vc
@@ -35,6 +35,7 @@ BENCH_OBJECTS = \
$(OBJS)\bench_htmlpars.obj \
$(OBJS)\bench_htmltag.obj \
$(OBJS)\bench_ipcclient.obj \
+ $(OBJS)\bench_log.obj \
$(OBJS)\bench_mbconv.obj \
$(OBJS)\bench_strings.obj \
$(OBJS)\bench_tls.obj \
@@ -312,6 +313,9 @@ $(OBJS)\bench_htmltag.obj: .\htmlparser\htmltag.cpp
$(OBJS)\bench_ipcclient.obj: .\ipcclient.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\ipcclient.cpp
+$(OBJS)\bench_log.obj: .\log.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\log.cpp
+
$(OBJS)\bench_mbconv.obj: .\mbconv.cpp
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\mbconv.cpp
diff --git a/tests/benchmarks/makefile.wat b/tests/benchmarks/makefile.wat
index 8fef04aa72..462de49e2b 100644
--- a/tests/benchmarks/makefile.wat
+++ b/tests/benchmarks/makefile.wat
@@ -230,6 +230,7 @@ BENCH_OBJECTS = &
$(OBJS)\bench_htmlpars.obj &
$(OBJS)\bench_htmltag.obj &
$(OBJS)\bench_ipcclient.obj &
+ $(OBJS)\bench_log.obj &
$(OBJS)\bench_mbconv.obj &
$(OBJS)\bench_strings.obj &
$(OBJS)\bench_tls.obj &
@@ -283,6 +284,9 @@ $(OBJS)\bench_htmltag.obj : .AUTODEPEND .\htmlparser\htmltag.cpp
$(OBJS)\bench_ipcclient.obj : .AUTODEPEND .\ipcclient.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BENCH_CXXFLAGS) $<
+$(OBJS)\bench_log.obj : .AUTODEPEND .\log.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(BENCH_CXXFLAGS) $<
+
$(OBJS)\bench_mbconv.obj : .AUTODEPEND .\mbconv.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(BENCH_CXXFLAGS) $<