From 308e6a7d73c8149972e2c8d0eb7ccc818626c968 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 8 Nov 2018 22:41:28 +0000 Subject: [PATCH] .benchmarks git-svn-id: svn://ultimatepp.org/upp/trunk@12487 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- benchmarks/LionBenchmark/LionBenchmark.h | 1 + benchmarks/LionBenchmark/LionBenchmark.upp | 1 + benchmarks/LionBenchmark/PolyPolygon.cpp | 42 ++++++++++++++++++++++ benchmarks/LionBenchmark/main.cpp | 38 +++++++++++++++++--- benchmarks/PainterExamples/main.cpp | 4 ++- 5 files changed, 80 insertions(+), 6 deletions(-) create mode 100644 benchmarks/LionBenchmark/PolyPolygon.cpp diff --git a/benchmarks/LionBenchmark/LionBenchmark.h b/benchmarks/LionBenchmark/LionBenchmark.h index c623ae232..bb3347c70 100644 --- a/benchmarks/LionBenchmark/LionBenchmark.h +++ b/benchmarks/LionBenchmark/LionBenchmark.h @@ -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 diff --git a/benchmarks/LionBenchmark/LionBenchmark.upp b/benchmarks/LionBenchmark/LionBenchmark.upp index 69cc61ca8..941799ef1 100644 --- a/benchmarks/LionBenchmark/LionBenchmark.upp +++ b/benchmarks/LionBenchmark/LionBenchmark.upp @@ -9,6 +9,7 @@ file pythagoras.cpp, demo.cpp, Clipping.cpp, + PolyPolygon.cpp, main.cpp, info.txt; diff --git a/benchmarks/LionBenchmark/PolyPolygon.cpp b/benchmarks/LionBenchmark/PolyPolygon.cpp new file mode 100644 index 000000000..794df1f25 --- /dev/null +++ b/benchmarks/LionBenchmark/PolyPolygon.cpp @@ -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)); +} diff --git a/benchmarks/LionBenchmark/main.cpp b/benchmarks/LionBenchmark/main.cpp index b9645c43d..80292afc7 100644 --- a/benchmarks/LionBenchmark/main.cpp +++ b/benchmarks/LionBenchmark/main.cpp @@ -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 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); diff --git a/benchmarks/PainterExamples/main.cpp b/benchmarks/PainterExamples/main.cpp index c6ece2ca4..a947901a9 100644 --- a/benchmarks/PainterExamples/main.cpp +++ b/benchmarks/PainterExamples/main.cpp @@ -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;