Add a simple benchmark of wxDisplaySize() and related functions
This benchmark shows that wxGetDisplaySize() has only minimal overhead compared to wxDisplaySize(), but wxDisplay().GetGeometry() is almost 3 times slower (under wxGTK).
This commit is contained in:
parent
b4aaa10032
commit
d6793893c0
@ -64,6 +64,7 @@ BENCH_GUI_CXXFLAGS = -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
|
||||
BENCH_GUI_OBJECTS = \
|
||||
$(__bench_gui___win32rc) \
|
||||
bench_gui_bench.o \
|
||||
bench_gui_display.o \
|
||||
bench_gui_image.o
|
||||
BENCH_GRAPHICS_CXXFLAGS = -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \
|
||||
$(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \
|
||||
@ -306,6 +307,9 @@ bench_gui_sample_rc.o: $(srcdir)/../../samples/sample.rc
|
||||
bench_gui_bench.o: $(srcdir)/bench.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/bench.cpp
|
||||
|
||||
bench_gui_display.o: $(srcdir)/display.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/display.cpp
|
||||
|
||||
bench_gui_image.o: $(srcdir)/image.cpp
|
||||
$(CXXC) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(srcdir)/image.cpp
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
<sources>
|
||||
bench.cpp
|
||||
display.cpp
|
||||
image.cpp
|
||||
</sources>
|
||||
<wx-lib>core</wx-lib>
|
||||
|
@ -286,6 +286,9 @@
|
||||
<File
|
||||
RelativePath=".\bench.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\display.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\image.cpp">
|
||||
</File>
|
||||
|
@ -810,6 +810,10 @@
|
||||
RelativePath=".\bench.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\display.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\image.cpp"
|
||||
>
|
||||
|
@ -782,6 +782,10 @@
|
||||
RelativePath=".\bench.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\display.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\image.cpp"
|
||||
>
|
||||
|
30
tests/benchmarks/display.cpp
Normal file
30
tests/benchmarks/display.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: tests/benchmarks/display.cpp
|
||||
// Purpose: wxDisplay benchmarks
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2018-09-30
|
||||
// Copyright: (c) 2018 Vadim Zeitlin <vadim@wxwidgets.org>
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/display.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
#include "bench.h"
|
||||
|
||||
BENCHMARK_FUNC(DisplaySize)
|
||||
{
|
||||
int w, h;
|
||||
wxDisplaySize(&w, &h);
|
||||
return w > 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(GetDisplaySize)
|
||||
{
|
||||
return wxGetDisplaySize().x > 0;
|
||||
}
|
||||
|
||||
BENCHMARK_FUNC(DisplayGetGeometry)
|
||||
{
|
||||
return wxDisplay().GetGeometry().GetSize().x > 0;
|
||||
}
|
@ -54,6 +54,7 @@ BENCH_GUI_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \
|
||||
$(__DLLFLAG_p) -I.\..\..\samples -DNOPCH $(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_GUI_OBJECTS = \
|
||||
$(OBJS)\bench_gui_bench.obj \
|
||||
$(OBJS)\bench_gui_display.obj \
|
||||
$(OBJS)\bench_gui_image.obj
|
||||
BENCH_GRAPHICS_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \
|
||||
$(__OPTIMIZEFLAG) $(__THREADSFLAG_1) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
|
||||
@ -340,6 +341,9 @@ $(OBJS)\bench_gui_sample.res: .\..\..\samples\sample.rc
|
||||
$(OBJS)\bench_gui_bench.obj: .\bench.cpp
|
||||
$(CXX) -q -c -P -o$@ $(BENCH_GUI_CXXFLAGS) .\bench.cpp
|
||||
|
||||
$(OBJS)\bench_gui_display.obj: .\display.cpp
|
||||
$(CXX) -q -c -P -o$@ $(BENCH_GUI_CXXFLAGS) .\display.cpp
|
||||
|
||||
$(OBJS)\bench_gui_image.obj: .\image.cpp
|
||||
$(CXX) -q -c -P -o$@ $(BENCH_GUI_CXXFLAGS) .\image.cpp
|
||||
|
||||
|
@ -49,6 +49,7 @@ BENCH_GUI_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
|
||||
BENCH_GUI_OBJECTS = \
|
||||
$(OBJS)\bench_gui_sample_rc.o \
|
||||
$(OBJS)\bench_gui_bench.o \
|
||||
$(OBJS)\bench_gui_display.o \
|
||||
$(OBJS)\bench_gui_image.o
|
||||
BENCH_GRAPHICS_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
|
||||
$(GCCFLAGS) -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
|
||||
@ -318,6 +319,9 @@ $(OBJS)\bench_gui_sample_rc.o: ./../../samples/sample.rc
|
||||
$(OBJS)\bench_gui_bench.o: ./bench.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_gui_display.o: ./display.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
$(OBJS)\bench_gui_image.o: ./image.cpp
|
||||
$(CXX) -c -o $@ $(BENCH_GUI_CXXFLAGS) $(CPPDEPS) $<
|
||||
|
||||
|
@ -51,6 +51,7 @@ BENCH_GUI_CXXFLAGS = /M$(__RUNTIME_LIBS_26)$(__DEBUGRUNTIME) /DWIN32 \
|
||||
/DNOPCH /D_CONSOLE $(__RTTIFLAG) $(__EXCEPTIONSFLAG) $(CPPFLAGS) $(CXXFLAGS)
|
||||
BENCH_GUI_OBJECTS = \
|
||||
$(OBJS)\bench_gui_bench.obj \
|
||||
$(OBJS)\bench_gui_display.obj \
|
||||
$(OBJS)\bench_gui_image.obj
|
||||
BENCH_GUI_RESOURCES = \
|
||||
$(OBJS)\bench_gui_sample.res
|
||||
@ -512,6 +513,9 @@ $(OBJS)\bench_gui_sample.res: .\..\..\samples\sample.rc
|
||||
$(OBJS)\bench_gui_bench.obj: .\bench.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\bench.cpp
|
||||
|
||||
$(OBJS)\bench_gui_display.obj: .\display.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\display.cpp
|
||||
|
||||
$(OBJS)\bench_gui_image.obj: .\image.cpp
|
||||
$(CXX) /c /nologo /TP /Fo$@ $(BENCH_GUI_CXXFLAGS) .\image.cpp
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user