.benchmarks

git-svn-id: svn://ultimatepp.org/upp/trunk@12487 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2018-11-08 22:41:28 +00:00
parent af93b0fcdc
commit 308e6a7d73
5 changed files with 80 additions and 6 deletions

View file

@ -10,5 +10,6 @@ void PaintLion(Painter& sw);
void PythagorasTree(Painter& sw);
void Demo(Painter& sw);
void ClippingExample(Painter& sw);
void PolyPolygon(Painter& sw);
#endif

View file

@ -9,6 +9,7 @@ file
pythagoras.cpp,
demo.cpp,
Clipping.cpp,
PolyPolygon.cpp,
main.cpp,
info.txt;

View file

@ -0,0 +1,42 @@
#include "LionBenchmark.h"
void PolyPolygon(Painter& sw)
{
Point points[12][2][4];
int subpolygon_counts[12][2];
int disjunct_counts[12];
Point lpoints[12][5];
int lcounts[12][2];
Pointf center(400, 300);
static const double out_delta = 2 * M_PI / 24;
static const double in_delta = 2 * M_PI / 48;
for(int i = 0; i < 12; i++) {
double angle = i * 2 * M_PI / 12;
points[i][0][0] = Polar(center, 200, angle);
points[i][0][1] = Polar(center, 120, angle - out_delta);
points[i][0][2] = Polar(center, 40, angle);
points[i][0][3] = Polar(center, 120, angle + out_delta);
points[i][1][0] = Polar(center, 160, angle);
points[i][1][1] = Polar(center, 120, angle + in_delta);
points[i][1][2] = Polar(center, 80, angle);
points[i][1][3] = Polar(center, 120, angle - in_delta);
subpolygon_counts[i][0] = 4;
subpolygon_counts[i][1] = 4;
disjunct_counts[i] = subpolygon_counts[i][0] + subpolygon_counts[i][1];
lpoints[i][0] = Polar(center, 260, angle + in_delta);
lpoints[i][1] = Polar(center, 230, angle);
lpoints[i][2] = Polar(center, 260, angle - in_delta);
lcounts[i][0] = 3;
lpoints[i][3] = Polar(center, 280, angle + in_delta);
lpoints[i][4] = Polar(center, 280, angle - in_delta);
lcounts[i][1] = 2;
}
sw.DrawPolyPolyPolygon(points[0][0], sizeof(points) / sizeof(Point),
subpolygon_counts[0], sizeof(subpolygon_counts) / sizeof(int),
disjunct_counts, sizeof(disjunct_counts) / sizeof(int),
LtBlue(), 4, LtRed(), I64(0xF0F0F0F00F0F0F0F));
// sw.DrawPolyPolyline(lpoints[0], sizeof(lpoints) / sizeof(Point),
// lcounts[0], sizeof(lcounts) / sizeof(int),
// 4, Color(0, 192, 0));
}

View file

@ -5,12 +5,17 @@ double tm[4];
void Task(Painter& sw)
{
RTIMING("Total");
sw.Begin();
// sw.Scale(2);
// sw.Opacity(0.3);
// sw.Translate(20, 0);
// sw.Rotate(0.1);
// PaintLion(sw);
// PythagorasTree(sw);
Demo(sw);
// Demo(sw);
// ClippingExample(sw);
PolyPolygon(sw);
sw.End();
}
struct MyApp : public TopWindow {
@ -25,16 +30,17 @@ struct MyApp : public TopWindow {
virtual void Paint(Draw& w) {
w.DrawRect(GetSize(), White());
for(int pass = 0; pass < 2; pass++) {
ImageBuffer ib(1200, 1200);
for(int pass = 0; pass < 1; pass++) {
ImageBuffer ib(1200, 800);
{
BufferPainter sw(ib);
if(pass)
sw.Co();
sw.PreClip();
sw.Clear(White());
Task(sw);
}
w.DrawImage(0, 500 * pass, ib);
w.DrawImage(0, 800 * pass, ib);
}
int x = 1200;
@ -48,8 +54,30 @@ struct MyApp : public TopWindow {
}
};
struct DashInfo {};
struct BaseAttr {
Xform2D mtx;
bool evenodd;
byte join;
byte cap;
bool invert;
double miter_limit;
double opacity;
DashInfo *dash;
};
BaseAttr a, b;
GUI_APP_MAIN
{
RDUMP(sizeof(BaseAttr));
Array<BaseAttr> h;
__BREAK__;
memcpy(&h.Add(), &a, sizeof(BaseAttr));
return;
#if 1 && !defined(_DEBUG)
RDUMP(MemoryUsedKb());
@ -61,7 +89,7 @@ GUI_APP_MAIN
sw.Co();
// for(int i = 0; i < 10; i++)
PaintLion(sw);
for(int pass = 0; pass < 2; pass++) {
for(int pass = 0; pass < 4; pass++) {
int time0 = msecs();
int n = 0;
BufferPainter sw(ib);

View file

@ -57,7 +57,7 @@ void App::Print()
void App::Benchmark()
{
double tm[2];
ImageBuffer ib(1024, 768);
ImageBuffer ib(2000, 2000);
for(int pass = 0; pass < 1 + !!ctrl.mt; pass++) {
int time0 = GetTickCount();
int n = 0;
@ -67,7 +67,9 @@ void App::Benchmark()
time = GetTickCount();
if(time - time0 > 1000) break;
sw.Co(pass);
sw.Begin();
DoPaint(sw);
sw.End();
n++;
}
tm[pass] = double(time - time0) / n;