From bf0f3b269fc8f989b278a2d9f32846657dfd53ed Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 23 May 2011 11:06:48 +0000 Subject: [PATCH] Add a trivial benchmark for wxDateTime::ParseDate(). Add a test to check the performance of this method. See #13242. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67775 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- tests/benchmarks/Makefile.in | 4 ++++ tests/benchmarks/bench.bkl | 1 + tests/benchmarks/bench.dsp | 4 ++++ tests/benchmarks/bench_vc7.vcproj | 3 +++ tests/benchmarks/bench_vc8.vcproj | 4 ++++ tests/benchmarks/bench_vc9.vcproj | 4 ++++ tests/benchmarks/datetime.cpp | 20 ++++++++++++++++++++ tests/benchmarks/makefile.bcc | 4 ++++ tests/benchmarks/makefile.gcc | 4 ++++ tests/benchmarks/makefile.vc | 4 ++++ tests/benchmarks/makefile.wat | 4 ++++ 11 files changed, 56 insertions(+) create mode 100644 tests/benchmarks/datetime.cpp diff --git a/tests/benchmarks/Makefile.in b/tests/benchmarks/Makefile.in index 8c4d1960e2..0c638533a9 100644 --- a/tests/benchmarks/Makefile.in +++ b/tests/benchmarks/Makefile.in @@ -43,6 +43,7 @@ BENCH_CXXFLAGS = -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \ $(CXXFLAGS) BENCH_OBJECTS = \ bench_bench.o \ + bench_datetime.o \ bench_htmlpars.o \ bench_htmltag.o \ bench_ipcclient.o \ @@ -131,6 +132,9 @@ data: bench_bench.o: $(srcdir)/bench.cpp $(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/bench.cpp +bench_datetime.o: $(srcdir)/datetime.cpp + $(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/datetime.cpp + bench_htmlpars.o: $(srcdir)/htmlparser/htmlpars.cpp $(CXXC) -c -o $@ $(BENCH_CXXFLAGS) $(srcdir)/htmlparser/htmlpars.cpp diff --git a/tests/benchmarks/bench.bkl b/tests/benchmarks/bench.bkl index 0b7c329173..452900a95f 100644 --- a/tests/benchmarks/bench.bkl +++ b/tests/benchmarks/bench.bkl @@ -11,6 +11,7 @@ template_append="wx_append_base"> bench.cpp + datetime.cpp htmlparser/htmlpars.cpp htmlparser/htmltag.cpp ipcclient.cpp diff --git a/tests/benchmarks/bench.dsp b/tests/benchmarks/bench.dsp index fa92335ffe..f87807d078 100644 --- a/tests/benchmarks/bench.dsp +++ b/tests/benchmarks/bench.dsp @@ -239,6 +239,10 @@ SOURCE=.\bench.cpp # End Source File # Begin Source File +SOURCE=.\datetime.cpp +# End Source File +# Begin Source File + SOURCE=.\htmlparser\htmlpars.cpp # End Source File # Begin Source File diff --git a/tests/benchmarks/bench_vc7.vcproj b/tests/benchmarks/bench_vc7.vcproj index 41b6c37f9d..0968742ce1 100644 --- a/tests/benchmarks/bench_vc7.vcproj +++ b/tests/benchmarks/bench_vc7.vcproj @@ -544,6 +544,9 @@ + + diff --git a/tests/benchmarks/bench_vc8.vcproj b/tests/benchmarks/bench_vc8.vcproj index ddafa8a631..d206538dc5 100644 --- a/tests/benchmarks/bench_vc8.vcproj +++ b/tests/benchmarks/bench_vc8.vcproj @@ -807,6 +807,10 @@ RelativePath=".\bench.cpp" > + + diff --git a/tests/benchmarks/bench_vc9.vcproj b/tests/benchmarks/bench_vc9.vcproj index 0400f4e5b6..55726ee9c7 100644 --- a/tests/benchmarks/bench_vc9.vcproj +++ b/tests/benchmarks/bench_vc9.vcproj @@ -779,6 +779,10 @@ RelativePath=".\bench.cpp" > + + diff --git a/tests/benchmarks/datetime.cpp b/tests/benchmarks/datetime.cpp new file mode 100644 index 0000000000..3be9ddcf89 --- /dev/null +++ b/tests/benchmarks/datetime.cpp @@ -0,0 +1,20 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: tests/benchmarks/datetime.cpp +// Purpose: wxDateTime benchmarks +// Author: Vadim Zeitlin +// Created: 2011-05-23 +// RCS-ID: $Id$ +// Copyright: (c) 2011 Vadim Zeitlin +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/datetime.h" + +#include "bench.h" + +BENCHMARK_FUNC(ParseDate) +{ + wxDateTime dt; + return dt.ParseDate("May 23, 2011") && dt.GetMonth() == wxDateTime::May; +} + diff --git a/tests/benchmarks/makefile.bcc b/tests/benchmarks/makefile.bcc index b818d6d7b1..6dab7dabab 100644 --- a/tests/benchmarks/makefile.bcc +++ b/tests/benchmarks/makefile.bcc @@ -37,6 +37,7 @@ BENCH_CXXFLAGS = $(__RUNTIME_LIBS_7) -I$(BCCDIR)\include $(__DEBUGINFO) \ $(CPPFLAGS) $(CXXFLAGS) BENCH_OBJECTS = \ $(OBJS)\bench_bench.obj \ + $(OBJS)\bench_datetime.obj \ $(OBJS)\bench_htmlpars.obj \ $(OBJS)\bench_htmltag.obj \ $(OBJS)\bench_ipcclient.obj \ @@ -212,6 +213,9 @@ data: $(OBJS)\bench_bench.obj: .\bench.cpp $(CXX) -q -c -P -o$@ $(BENCH_CXXFLAGS) .\bench.cpp +$(OBJS)\bench_datetime.obj: .\datetime.cpp + $(CXX) -q -c -P -o$@ $(BENCH_CXXFLAGS) .\datetime.cpp + $(OBJS)\bench_htmlpars.obj: .\htmlparser\htmlpars.cpp $(CXX) -q -c -P -o$@ $(BENCH_CXXFLAGS) .\htmlparser\htmlpars.cpp diff --git a/tests/benchmarks/makefile.gcc b/tests/benchmarks/makefile.gcc index 71e83e157c..22a562f5af 100644 --- a/tests/benchmarks/makefile.gcc +++ b/tests/benchmarks/makefile.gcc @@ -30,6 +30,7 @@ BENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG_2) $(__THREADSFLAG) \ $(CXXFLAGS) BENCH_OBJECTS = \ $(OBJS)\bench_bench.o \ + $(OBJS)\bench_datetime.o \ $(OBJS)\bench_htmlpars.o \ $(OBJS)\bench_htmltag.o \ $(OBJS)\bench_ipcclient.o \ @@ -198,6 +199,9 @@ data: $(OBJS)\bench_bench.o: ./bench.cpp $(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\bench_datetime.o: ./datetime.cpp + $(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\bench_htmlpars.o: ./htmlparser/htmlpars.cpp $(CXX) -c -o $@ $(BENCH_CXXFLAGS) $(CPPDEPS) $< diff --git a/tests/benchmarks/makefile.vc b/tests/benchmarks/makefile.vc index ab4b76b129..417dbbcb68 100644 --- a/tests/benchmarks/makefile.vc +++ b/tests/benchmarks/makefile.vc @@ -31,6 +31,7 @@ BENCH_CXXFLAGS = /M$(__RUNTIME_LIBS_10)$(__DEBUGRUNTIME_4) /DWIN32 \ $(CXXFLAGS) BENCH_OBJECTS = \ $(OBJS)\bench_bench.obj \ + $(OBJS)\bench_datetime.obj \ $(OBJS)\bench_htmlpars.obj \ $(OBJS)\bench_htmltag.obj \ $(OBJS)\bench_ipcclient.obj \ @@ -299,6 +300,9 @@ data: $(OBJS)\bench_bench.obj: .\bench.cpp $(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\bench.cpp +$(OBJS)\bench_datetime.obj: .\datetime.cpp + $(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\datetime.cpp + $(OBJS)\bench_htmlpars.obj: .\htmlparser\htmlpars.cpp $(CXX) /c /nologo /TP /Fo$@ $(BENCH_CXXFLAGS) .\htmlparser\htmlpars.cpp diff --git a/tests/benchmarks/makefile.wat b/tests/benchmarks/makefile.wat index c768080932..61ba44e23f 100644 --- a/tests/benchmarks/makefile.wat +++ b/tests/benchmarks/makefile.wat @@ -226,6 +226,7 @@ BENCH_CXXFLAGS = $(__DEBUGINFO_0) $(__OPTIMIZEFLAG_2) $(__THREADSFLAG_5) & $(__EXCEPTIONSFLAG_8) $(CPPFLAGS) $(CXXFLAGS) BENCH_OBJECTS = & $(OBJS)\bench_bench.obj & + $(OBJS)\bench_datetime.obj & $(OBJS)\bench_htmlpars.obj & $(OBJS)\bench_htmltag.obj & $(OBJS)\bench_ipcclient.obj & @@ -270,6 +271,9 @@ data : .SYMBOLIC $(OBJS)\bench_bench.obj : .AUTODEPEND .\bench.cpp $(CXX) -bt=nt -zq -fo=$^@ $(BENCH_CXXFLAGS) $< +$(OBJS)\bench_datetime.obj : .AUTODEPEND .\datetime.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(BENCH_CXXFLAGS) $< + $(OBJS)\bench_htmlpars.obj : .AUTODEPEND .\htmlparser\htmlpars.cpp $(CXX) -bt=nt -zq -fo=$^@ $(BENCH_CXXFLAGS) $< -- 2.45.2