Implemented new drawing benchmarks.
Since for some renderers circles and/or ellipses are basic figures so it would be worth to test the performance of drawing them. Respective tests are enabled with new command line options: "--circles" or "--ellipses".
This commit is contained in:
@@ -61,7 +61,9 @@ struct GraphicsBenchmarkOptions
|
|||||||
testImages =
|
testImages =
|
||||||
testLines =
|
testLines =
|
||||||
testRawBitmaps =
|
testRawBitmaps =
|
||||||
testRectangles = false;
|
testRectangles =
|
||||||
|
testCircles =
|
||||||
|
testEllipses = false;
|
||||||
|
|
||||||
usePaint =
|
usePaint =
|
||||||
useClient =
|
useClient =
|
||||||
@@ -84,7 +86,9 @@ struct GraphicsBenchmarkOptions
|
|||||||
testImages,
|
testImages,
|
||||||
testLines,
|
testLines,
|
||||||
testRawBitmaps,
|
testRawBitmaps,
|
||||||
testRectangles;
|
testRectangles,
|
||||||
|
testCircles,
|
||||||
|
testEllipses;
|
||||||
|
|
||||||
bool usePaint,
|
bool usePaint,
|
||||||
useClient,
|
useClient,
|
||||||
@@ -254,6 +258,7 @@ private:
|
|||||||
void OnPaint(wxPaintEvent& WXUNUSED(event))
|
void OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if ( opts.usePaint )
|
if ( opts.usePaint )
|
||||||
|
{
|
||||||
{
|
{
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
wxGCDC gcdc;
|
wxGCDC gcdc;
|
||||||
@@ -264,8 +269,15 @@ private:
|
|||||||
}
|
}
|
||||||
BenchmarkDCAndGC("paint", dc, gcdc);
|
BenchmarkDCAndGC("paint", dc, gcdc);
|
||||||
}
|
}
|
||||||
|
// Since some renderers use back buffers and hence
|
||||||
|
// drawing results are not displayed when the test
|
||||||
|
// is running then wait a second after graphics
|
||||||
|
// contents is commited to DC to present the output.
|
||||||
|
wxSleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
if ( opts.useClient )
|
if ( opts.useClient )
|
||||||
|
{
|
||||||
{
|
{
|
||||||
wxClientDC dc(this);
|
wxClientDC dc(this);
|
||||||
wxGCDC gcdc;
|
wxGCDC gcdc;
|
||||||
@@ -276,6 +288,12 @@ private:
|
|||||||
}
|
}
|
||||||
BenchmarkDCAndGC("client", dc, gcdc);
|
BenchmarkDCAndGC("client", dc, gcdc);
|
||||||
}
|
}
|
||||||
|
// Since some renderers use back buffers and hence
|
||||||
|
// drawing results are not displayed when the test
|
||||||
|
// is running then wait a second after graphics
|
||||||
|
// contents is commited to DC to present the output.
|
||||||
|
wxSleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
if ( opts.useMemory )
|
if ( opts.useMemory )
|
||||||
{
|
{
|
||||||
@@ -351,6 +369,8 @@ private:
|
|||||||
BenchmarkLines(msg, dc);
|
BenchmarkLines(msg, dc);
|
||||||
BenchmarkRawBitmaps(msg, dc);
|
BenchmarkRawBitmaps(msg, dc);
|
||||||
BenchmarkRectangles(msg, dc);
|
BenchmarkRectangles(msg, dc);
|
||||||
|
BenchmarkCircles(msg, dc);
|
||||||
|
BenchmarkEllipses(msg, dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BenchmarkLines(const wxString& msg, wxDC& dc)
|
void BenchmarkLines(const wxString& msg, wxDC& dc)
|
||||||
@@ -417,6 +437,66 @@ private:
|
|||||||
opts.numIters, t, (1000. * t)/opts.numIters);
|
opts.numIters, t, (1000. * t)/opts.numIters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BenchmarkCircles(const wxString& msg, wxDC& dc)
|
||||||
|
{
|
||||||
|
if ( !opts.testCircles )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( opts.mapMode != 0 )
|
||||||
|
dc.SetMapMode((wxMappingMode)opts.mapMode);
|
||||||
|
if ( opts.penWidth != 0 )
|
||||||
|
dc.SetPen(wxPen(*wxWHITE, opts.penWidth));
|
||||||
|
|
||||||
|
dc.SetBrush( *wxGREEN_BRUSH );
|
||||||
|
|
||||||
|
wxPrintf("Benchmarking %s: ", msg);
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
wxStopWatch sw;
|
||||||
|
for ( long n = 0; n < opts.numIters; n++ )
|
||||||
|
{
|
||||||
|
int x = rand() % opts.width,
|
||||||
|
y = rand() % opts.height;
|
||||||
|
|
||||||
|
dc.DrawCircle(x, y, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
const long t = sw.Time();
|
||||||
|
|
||||||
|
wxPrintf("%ld circles done in %ldms = %gus/circle\n",
|
||||||
|
opts.numIters, t, (1000. * t)/opts.numIters);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BenchmarkEllipses(const wxString& msg, wxDC& dc)
|
||||||
|
{
|
||||||
|
if ( !opts.testEllipses )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( opts.mapMode != 0 )
|
||||||
|
dc.SetMapMode((wxMappingMode)opts.mapMode);
|
||||||
|
if ( opts.penWidth != 0 )
|
||||||
|
dc.SetPen(wxPen(*wxWHITE, opts.penWidth));
|
||||||
|
|
||||||
|
dc.SetBrush( *wxBLUE_BRUSH );
|
||||||
|
|
||||||
|
wxPrintf("Benchmarking %s: ", msg);
|
||||||
|
fflush(stdout);
|
||||||
|
|
||||||
|
wxStopWatch sw;
|
||||||
|
for ( long n = 0; n < opts.numIters; n++ )
|
||||||
|
{
|
||||||
|
int x = rand() % opts.width,
|
||||||
|
y = rand() % opts.height;
|
||||||
|
|
||||||
|
dc.DrawEllipse(x, y, 48, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
const long t = sw.Time();
|
||||||
|
|
||||||
|
wxPrintf("%ld ellipses done in %ldms = %gus/ellipse\n",
|
||||||
|
opts.numIters, t, (1000. * t)/opts.numIters);
|
||||||
|
}
|
||||||
|
|
||||||
void BenchmarkBitmaps(const wxString& msg, wxDC& dc)
|
void BenchmarkBitmaps(const wxString& msg, wxDC& dc)
|
||||||
{
|
{
|
||||||
if ( !opts.testBitmaps )
|
if ( !opts.testBitmaps )
|
||||||
@@ -559,6 +639,8 @@ public:
|
|||||||
{ wxCMD_LINE_SWITCH, "", "lines" },
|
{ wxCMD_LINE_SWITCH, "", "lines" },
|
||||||
{ wxCMD_LINE_SWITCH, "", "rawbmp" },
|
{ wxCMD_LINE_SWITCH, "", "rawbmp" },
|
||||||
{ wxCMD_LINE_SWITCH, "", "rectangles" },
|
{ wxCMD_LINE_SWITCH, "", "rectangles" },
|
||||||
|
{ wxCMD_LINE_SWITCH, "", "circles" },
|
||||||
|
{ wxCMD_LINE_SWITCH, "", "ellipses" },
|
||||||
{ wxCMD_LINE_SWITCH, "", "paint" },
|
{ wxCMD_LINE_SWITCH, "", "paint" },
|
||||||
{ wxCMD_LINE_SWITCH, "", "client" },
|
{ wxCMD_LINE_SWITCH, "", "client" },
|
||||||
{ wxCMD_LINE_SWITCH, "", "memory" },
|
{ wxCMD_LINE_SWITCH, "", "memory" },
|
||||||
@@ -601,15 +683,20 @@ public:
|
|||||||
opts.testLines = parser.Found("lines");
|
opts.testLines = parser.Found("lines");
|
||||||
opts.testRawBitmaps = parser.Found("rawbmp");
|
opts.testRawBitmaps = parser.Found("rawbmp");
|
||||||
opts.testRectangles = parser.Found("rectangles");
|
opts.testRectangles = parser.Found("rectangles");
|
||||||
|
opts.testCircles = parser.Found("circles");
|
||||||
|
opts.testEllipses = parser.Found("ellipses");
|
||||||
if ( !(opts.testBitmaps || opts.testImages || opts.testLines
|
if ( !(opts.testBitmaps || opts.testImages || opts.testLines
|
||||||
|| opts.testRawBitmaps || opts.testRectangles) )
|
|| opts.testRawBitmaps || opts.testRectangles
|
||||||
|
|| opts.testCircles || opts.testEllipses) )
|
||||||
{
|
{
|
||||||
// Do everything by default.
|
// Do everything by default.
|
||||||
opts.testBitmaps =
|
opts.testBitmaps =
|
||||||
opts.testImages =
|
opts.testImages =
|
||||||
opts.testLines =
|
opts.testLines =
|
||||||
opts.testRawBitmaps =
|
opts.testRawBitmaps =
|
||||||
opts.testRectangles = true;
|
opts.testRectangles =
|
||||||
|
opts.testCircles =
|
||||||
|
opts.testEllipses = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.usePaint = parser.Found("paint");
|
opts.usePaint = parser.Found("paint");
|
||||||
|
Reference in New Issue
Block a user