+ opts.numIters, t, (1000. * t)/opts.numIters);
+ }
+
+ void BenchmarkImages(const wxString& msg, wxDC& dc)
+ {
+ if ( !opts.testImages )
+ return;
+
+ if ( opts.mapMode != 0 )
+ dc.SetMapMode((wxMappingMode)opts.mapMode);
+
+ wxPrintf("Benchmarking %s: ", msg);
+ fflush(stdout);
+
+ wxImage image(wxSize(opts.width, opts.height), false /* don't clear */);
+
+ wxStopWatch sw;
+ for ( int n = 0; n < opts.numIters; n++ )
+ {
+ UpdateRGB(image.GetData(), n);
+ dc.DrawBitmap(image, 0, 0);
+ }
+
+ const long t = sw.Time();
+
+ wxPrintf("%ld images done in %ldms = %gus/image or %ld FPS\n",
+ opts.numIters, t, (1000. * t)/opts.numIters,
+ (1000*opts.numIters + t - 1)/t);
+ }
+
+ void BenchmarkRawBitmaps(const wxString& msg, wxDC& dc)
+ {
+ if ( !opts.testRawBitmaps )
+ return;
+
+ if ( opts.mapMode != 0 )
+ dc.SetMapMode((wxMappingMode)opts.mapMode);
+
+ wxPrintf("Benchmarking %s: ", msg);
+ fflush(stdout);
+
+ wxBitmap bitmap(opts.width, opts.height, 24);
+ wxNativePixelData data(bitmap);
+
+ wxStopWatch sw;
+ for ( int n = 0; n < opts.numIters; n++ )
+ {
+ unsigned char c = n % 256;
+ {
+ wxNativePixelData::Iterator p(data);
+ for ( int y = 0; y < opts.height; ++y )
+ {
+ wxNativePixelData::Iterator rowStart = p;
+
+ for ( int x = 0; x < opts.width; ++x )
+ {
+ p.Red() =
+ p.Green() =
+ p.Blue() = c;
+ ++p;
+ }
+
+ p = rowStart;
+ p.OffsetY(data, 1);
+ c++;
+ }
+ }
+
+ dc.DrawBitmap(bitmap, 0, 0);
+ }
+
+ const long t = sw.Time();
+
+ wxPrintf("%ld raw bitmaps done in %ldms = %gus/bitmap or %ld FPS\n",
+ opts.numIters, t, (1000. * t)/opts.numIters,
+ (1000*opts.numIters + t - 1)/t);