ultimatepp/benchmarks/LionBenchmark/main.cpp
cxl aad67fd761 .benchmarks
git-svn-id: svn://ultimatepp.org/upp/trunk@11613 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2017-12-25 10:42:01 +00:00

60 lines
1.2 KiB
C++

#include "LionBenchmark.h"
double tm[2];
struct MyApp : public TopWindow {
bool co = true;
virtual void LeftDown(Point p, dword keyflags)
{
co = !co;
Refresh();
}
virtual void Paint(Draw& w) {
RLOG("========== PAINT");
ImageBuffer ib(GetSize());
{
BufferPainter sw(ib);
sw.Co(co);
sw.Clear(White());
// sw.Scale(2);
// sw.Opacity(0.98);
PaintLion(sw);
}
w.DrawImage(0, 0, ib);
w.DrawText(500, 0, Format("Standard %.4f", tm[0]));
w.DrawText(500, 50, Format("Multithreaded %.4f", tm[1]));
w.DrawText(500, 100, Format("Standard / Multithreaded %.4f", tm[0] / tm[1]));
w.DrawText(500, 150, co ? "MT" : "");
}
};
GUI_APP_MAIN
{
#if 1 && !defined(_DEBUG)
RDUMP(MemoryUsedKb());
PeakMemoryProfile();
ImageBuffer ib(1000, 1000);
BufferPainter sw(ib);
PaintLion(sw);
for(int pass = 0; pass < 2; pass++) {
int time0 = msecs();
int n = 0;
while(msecs(time0) < 1000) {
n++;
BufferPainter sw(ib);
sw.Co(pass);
// sw.Scale(2);
// sw.Opacity(0.3);
PaintLion(sw);
}
tm[pass] = (double)msecs(time0) / n;
}
RLOG("=========================");
RLOG(*PeakMemoryProfile());
RLOG("Standard " << tm[0]);
RLOG("MT " << tm[1]);
#endif
MyApp().Run();
}