From 82a0e285d89cbf74fae88d6c6d5a871e6eed8354 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 5 Jun 2016 21:58:18 +0200 Subject: [PATCH] Added drawing rounded rectangles to the graphics benchmark. This test is executed together with standard rectangles benchmark and both benchmarks are enabled with '--rectangles' option. --- tests/benchmarks/graphics.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/benchmarks/graphics.cpp b/tests/benchmarks/graphics.cpp index e86128ee8b..fd361bbffa 100644 --- a/tests/benchmarks/graphics.cpp +++ b/tests/benchmarks/graphics.cpp @@ -369,6 +369,7 @@ private: BenchmarkLines(msg, dc); BenchmarkRawBitmaps(msg, dc); BenchmarkRectangles(msg, dc); + BenchmarkRoundedRectangles(msg, dc); BenchmarkCircles(msg, dc); BenchmarkEllipses(msg, dc); } @@ -437,6 +438,36 @@ private: opts.numIters, t, (1000. * t)/opts.numIters); } + void BenchmarkRoundedRectangles(const wxString& msg, wxDC& dc) + { + if ( !opts.testRectangles ) + return; + + if ( opts.mapMode != 0 ) + dc.SetMapMode((wxMappingMode)opts.mapMode); + if ( opts.penWidth != 0 ) + dc.SetPen(wxPen(*wxWHITE, opts.penWidth)); + + dc.SetBrush( *wxCYAN_BRUSH ); + + wxPrintf("Benchmarking %s: ", msg); + fflush(stdout); + + wxStopWatch sw; + for ( int n = 0; n < opts.numIters; n++ ) + { + int x = rand() % opts.width, + y = rand() % opts.height; + + dc.DrawRoundedRectangle(x, y, 48, 32, 8); + } + + const long t = sw.Time(); + + wxPrintf("%ld rounded rects done in %ldms = %gus/rect\n", + opts.numIters, t, (1000. * t)/opts.numIters); + } + void BenchmarkCircles(const wxString& msg, wxDC& dc) { if ( !opts.testCircles )