From d34e8704f6dbbfc58aa5ba01510fb30c92ca3dd1 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 9 Nov 2018 08:45:42 +0000 Subject: [PATCH] .benchmarks git-svn-id: svn://ultimatepp.org/upp/trunk@12490 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- benchmarks/LionBenchmark/LionBenchmark.h | 6 ++++++ benchmarks/LionBenchmark/LionBenchmark.upp | 1 + benchmarks/LionBenchmark/PolyPolygon.cpp | 6 +++--- benchmarks/LionBenchmark/TextOnPath.cpp | 21 +++++++++++++++++++ benchmarks/LionBenchmark/demo.cpp | 17 +++++++++++---- benchmarks/LionBenchmark/main.cpp | 24 ++++++++++------------ 6 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 benchmarks/LionBenchmark/TextOnPath.cpp diff --git a/benchmarks/LionBenchmark/LionBenchmark.h b/benchmarks/LionBenchmark/LionBenchmark.h index bb3347c70..fdaf7172b 100644 --- a/benchmarks/LionBenchmark/LionBenchmark.h +++ b/benchmarks/LionBenchmark/LionBenchmark.h @@ -6,10 +6,16 @@ using namespace Upp; +#define IMAGECLASS TestImg +#define IMAGEFILE +#include + void PaintLion(Painter& sw); void PythagorasTree(Painter& sw); void Demo(Painter& sw); void ClippingExample(Painter& sw); void PolyPolygon(Painter& sw); +void TextOnPath(Painter& sw); +void Dash(Painter& sw); #endif diff --git a/benchmarks/LionBenchmark/LionBenchmark.upp b/benchmarks/LionBenchmark/LionBenchmark.upp index 941799ef1..1a1cee5ba 100644 --- a/benchmarks/LionBenchmark/LionBenchmark.upp +++ b/benchmarks/LionBenchmark/LionBenchmark.upp @@ -10,6 +10,7 @@ file demo.cpp, Clipping.cpp, PolyPolygon.cpp, + TextOnPath.cpp, main.cpp, info.txt; diff --git a/benchmarks/LionBenchmark/PolyPolygon.cpp b/benchmarks/LionBenchmark/PolyPolygon.cpp index 794df1f25..e92dbaa3c 100644 --- a/benchmarks/LionBenchmark/PolyPolygon.cpp +++ b/benchmarks/LionBenchmark/PolyPolygon.cpp @@ -36,7 +36,7 @@ void PolyPolygon(Painter& sw) 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)); + sw.DrawPolyPolyline(lpoints[0], sizeof(lpoints) / sizeof(Point), + lcounts[0], sizeof(lcounts) / sizeof(int), + 4, Color(0, 192, 0)); } diff --git a/benchmarks/LionBenchmark/TextOnPath.cpp b/benchmarks/LionBenchmark/TextOnPath.cpp new file mode 100644 index 000000000..61d4ed405 --- /dev/null +++ b/benchmarks/LionBenchmark/TextOnPath.cpp @@ -0,0 +1,21 @@ +#include "LionBenchmark.h" + +void TextOnPath(Painter& sw) +{ + Font fnt = Roman(100); + FontInfo fi = fnt.Info(); + double pos = 0; + const char *s = "Hello world, this is text on path!"; + int l = GetTextSize(s, fnt).cx; + double r = l / (2 * M_PI); + sw.Circle(300, 300, r).Stroke(1, Red()); + while(*s) { + double w = fi[*s]; + sw.BeginOnPath(pos + w / 2, true); + sw.Character(-w / 2, -fi.GetAscent(), *s++, fnt) + .Fill(0, -fi.GetAscent(), Yellow(), 0, fi.GetDescent(), Blue()) + .Stroke(1, Black()); + sw.End(); + pos += w; + } +} diff --git a/benchmarks/LionBenchmark/demo.cpp b/benchmarks/LionBenchmark/demo.cpp index b6a4ce041..194483aef 100644 --- a/benchmarks/LionBenchmark/demo.cpp +++ b/benchmarks/LionBenchmark/demo.cpp @@ -1,9 +1,5 @@ #include "LionBenchmark.h" -#define IMAGECLASS TestImg -#define IMAGEFILE -#include - #define IMAGECLASS TestImg #define IMAGEFILE #include @@ -28,3 +24,16 @@ void Demo(Painter& sw) sw.End(); } } + +void Dash(Painter& sw) +{ + sw.Move(50, 50).Line(400, 200).Dash("2").Stroke(5, Blue()); + sw.Translate(0, 10); + sw.Move(50, 50).Line(400, 200).Dash("10 5").Stroke(5, Blue()); + sw.Translate(0, 10); + sw.Move(50, 50).Line(400, 200).Dash("10 5 5 5").Stroke(5, Blue()); + sw.Translate(0, 10); + sw.Move(50, 50).Line(400, 200).Dash("1").Stroke(5, Blue()); + sw.Translate(0, 10); + sw.Move(50, 50).Line(400, 200).Dash("1 2 3 4 5").Stroke(5, Blue()); +} diff --git a/benchmarks/LionBenchmark/main.cpp b/benchmarks/LionBenchmark/main.cpp index 80292afc7..0a9ea9a7d 100644 --- a/benchmarks/LionBenchmark/main.cpp +++ b/benchmarks/LionBenchmark/main.cpp @@ -14,7 +14,10 @@ void Task(Painter& sw) // PythagorasTree(sw); // Demo(sw); // ClippingExample(sw); - PolyPolygon(sw); +// PolyPolygon(sw); +// TextOnPath(sw); + Dash(sw); + sw.End(); } @@ -71,13 +74,6 @@ 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()); @@ -89,15 +85,17 @@ GUI_APP_MAIN sw.Co(); // for(int i = 0; i < 10; i++) PaintLion(sw); - for(int pass = 0; pass < 4; pass++) { + for(int pass = 0; pass < 2; pass++) { int time0 = msecs(); int n = 0; - BufferPainter sw(ib); - while(msecs(time0) < 1000) { - n++; + { + BufferPainter sw(ib); sw.Co(pass & 1); sw.PreClip(pass & 2); - Task(sw); + while(msecs(time0) < 1000) { + n++; + Task(sw); + } } tm[pass] = (double)msecs(time0) / n; RLOG(pass << ": " << n << ", " << tm[pass] << " ms");