.benchmarks

git-svn-id: svn://ultimatepp.org/upp/trunk@14485 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-05-20 14:39:17 +00:00
parent 1d3802b8f1
commit c4d0d63aab
18 changed files with 185 additions and 263 deletions

View file

@ -1,99 +0,0 @@
Standard 0.982318271119843
MT 1.08342361863489
========== PAINT
TIMING Fill : 213.86 ms - 46.29 us (214.00 ms / 4620 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 4620
TIMING Rasterize : 174.86 ms - 37.85 us (175.00 ms / 4620 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 4620
TIMING Create : 167.07 ms - 5.30 us (168.00 ms / 31511 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 31511
---------------------------------------
RMAP
data.GetCount() = 132
Standard 1.38888888888889
MT 0.8424599831508
========== PAINT
TIMING Fill : 194.82 ms - 32.80 us (195.00 ms / 5940 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 5940
TIMING Rasterize : 398.82 ms - 67.14 us (399.00 ms / 5940 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 5940
TIMING Create : 2.81 ms - 70.28 ns ( 4.00 ms / 39925 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 39925
---------------------------------------
RINDEX
Standard 1.18906064209275
MT 0.768049155145929
========== PAINT
TIMING Fill : 248.82 ms - 38.19 us (249.00 ms / 6515 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 6515
TIMING Rasterize : 325.82 ms - 50.01 us (326.00 ms / 6515 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 6515
TIMING Create : 9.81 ms - 223.66 ns (11.00 ms / 43841 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 43841
--------------------------------------
RPTR
Standard 1.0989010989011
MT 0.727272727272727
========== PAINT
TIMING Fill : 276.81 ms - 40.26 us (277.00 ms / 6875 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 6875
TIMING Rasterize : 285.81 ms - 41.57 us (286.00 ms / 6875 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 6875
TIMING Create : 16.71 ms - 361.11 ns (18.00 ms / 46287 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 46287
--------------------------------------
RPTR 64
Standard 1.08342361863489
MT 0.612745098039216
========== PAINT
TIMING Fill : 139.88 ms - 28.57 us (140.00 ms / 4896 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 4896
TIMING Rasterize : 253.88 ms - 51.85 us (254.00 ms / 4896 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 4896
TIMING Create : 46.29 ms - 432.60 ns (49.00 ms / 107005 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 107005
--------------------------------------
RPTR 64 memset
Standard 1.06951871657754
MT 0.607533414337789
========== PAINT
TIMING Fill : 145.88 ms - 29.54 us (146.00 ms / 4938 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 4938
TIMING Rasterize : 297.88 ms - 60.32 us (298.00 ms / 4938 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 4938
TIMING Create : 38.30 ms - 354.90 ns (41.00 ms / 107927 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 107927
--------------------------------------
RPTR 64 memset, looper
Standard 1.07066381156317
MT 0.573065902578796
========== PAINT
TIMING Fill : 361.86 ms - 69.08 us (362.00 ms / 5238 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 5238
TIMING Rasterize : 296.86 ms - 56.67 us (297.00 ms / 5238 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 5238
TIMING Create : 51.87 ms - 453.28 ns (55.00 ms / 114425 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 114425
-------------------------------
FINAL 64
96 B, 378 allocated ( 35 KB), 0 fragmented ( 0 KB)
128 B, 1 allocated ( 0 KB), 30 fragmented ( 3 KB)
192 B, 11 allocated ( 2 KB), 10 fragmented ( 1 KB)
224 B, 1 allocated ( 0 KB), 17 fragmented ( 3 KB)
288 B, 1 allocated ( 0 KB), 13 fragmented ( 3 KB)
384 B, 1 allocated ( 0 KB), 9 fragmented ( 3 KB)
TOTAL, 393 allocated ( 38 KB), 79 fragmented ( 16 KB)
Free 4KB pages 0 (0 KB)
Large block count 0, total size 0 KB
Large fragments count 0, total size 0 KB
Large free 64KB pages 0, total size 0 KB
Big block count 1, total size 3907 KB
Standard 1.00908173562059
MT 0.538793103448276
========== PAINT
TIMING Finish : 674.85 ms - 121.14 us (675.00 ms / 5571 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 5571
TIMING Create : 38.67 ms - 317.78 ns (42.00 ms / 121697 ), min: 0.00 ns, max: 1.00 ms, nesting: 1 - 121697
--------------------------
Standard 0.816993464052287
MT 0.384763370527126
-----------------
Standard 0.791139240506329
MT 0.371609067261241

View file

@ -1,108 +0,0 @@
#include "LionBenchmark.h"
double tm[4];
void Task(Painter& sw)
{
RTIMING("Total");
sw.Begin();
// sw.Scale(1.2);
// sw.Opacity(0.3);
// sw.Translate(20, 0);
// sw.Rotate(0.1);
// PaintLion(sw);
// PythagorasTree(sw);
// Demo(sw);
// ClippingExample(sw);
// PolyPolygon(sw);
// TextOnPath(sw);
// Dash(sw);
SomeRocks(sw);
sw.End();
}
struct MyApp : public TopWindow {
bool co = true;
virtual void LeftDown(Point p, dword keyflags)
{
co = !co;
Refresh();
}
virtual void Paint(Draw& w) {
w.DrawRect(GetSize(), White());
for(int pass = 0; pass < 2; pass++) {
ImageBuffer ib(1200, 800);
{
BufferPainter sw(ib);
if(pass)
sw.Co();
sw.PreClip();
sw.Clear(White());
Task(sw);
}
w.DrawImage(0, 800 * pass, ib);
}
int x = 1200;
int y = 0;
w.DrawText(x, y += 50, Format("Standard %.4f", tm[0]));
w.DrawText(x, y += 50, Format("Multithreaded %.4f", tm[1]));
w.DrawText(x, y += 50, Format("Standard / Multithreaded %.4f", tm[0] / tm[1]));
w.DrawText(x, y += 50, Format("Preclipped Standard %.4f", tm[2]));
w.DrawText(x, y += 50, Format("Preclipped Multithreaded %.4f", tm[3]));
w.DrawText(x, y += 50, co ? "MT" : "");
}
};
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
{
#if 1 && !defined(_DEBUG)
RDUMP(MemoryUsedKb());
RDUMP(sizeof(Rasterizer));
// PeakMemoryProfile();
ImageBuffer ib(1200, 1200);
BufferPainter sw(ib);
sw.Co();
for(int pass = 0; pass < 2; pass++) {
int time0 = msecs();
int n = 0;
{
BufferPainter sw(ib);
sw.Co(pass & 1);
sw.PreClip(pass & 2);
while(msecs(time0) < 1000) {
n++;
Task(sw);
}
}
tm[pass] = (double)msecs(time0) / n;
RLOG(pass << ": " << n << ", " << tm[pass] << " ms");
}
RLOG("=========================");
// RLOG(*PeakMemoryProfile());
RLOG("Standard " << tm[0]);
RLOG("MT " << tm[1]);
#endif
MyApp().Title("6").Run();
}

View file

@ -7,15 +7,17 @@
using namespace Upp;
#define IMAGECLASS TestImg
#define IMAGEFILE <LionBenchmark/test.iml>
#define IMAGEFILE <PainterBenchmark/test.iml>
#include <Draw/iml_header.h>
void PaintLion(Painter& sw);
void PaintLionLarge(Painter& sw);
void PythagorasTree(Painter& sw);
void Demo(Painter& sw);
void ClippingExample(Painter& sw);
void PolyPolygon(Painter& sw);
void TextOnPath(Painter& sw);
void TextRotated(Painter& sw);
void Dash(Painter& sw);
void SomeRocks(Painter& sw);

View file

@ -11,6 +11,7 @@ file
Clipping.cpp,
PolyPolygon.cpp,
TextOnPath.cpp,
TextRotated.cpp,
SomeRocks.cpp,
main.cpp,
info.txt;

View file

@ -0,0 +1,7 @@
#include "LionBenchmark.h"
void TextRotated(Painter& sw)
{
for(int angle = 0; angle < 360; angle += 30)
sw.DrawText(250, 250, angle * 10, "x Text with angle " + AsString(angle));
}

View file

@ -1,7 +1,7 @@
#include "LionBenchmark.h"
#define IMAGECLASS TestImg
#define IMAGEFILE <LionBenchmark/test.iml>
#define IMAGEFILE <PainterBenchmark/test.iml>
#include <Draw/iml_source.h>
void Demo(Painter& sw)

View file

@ -0,0 +1,36 @@
NEW:
PaintLionLarge 1K: 0.803 ms
PaintLionLarge 1K Co: 0.222 ms
PaintLionLarge 1K PreClip: 0.809 ms
PaintLionLarge 1K PreClip Co: 0.214 ms
PaintLionLarge 1K Cleared: 0.820 ms
PaintLionLarge 1K Cleared Co: 0.287 ms
PaintLionLarge 1K Cleared PreClip: 0.813 ms
PaintLionLarge 1K Cleared PreClip Co: 0.278 ms
PaintLionLarge 4K: 1.916 ms
PaintLionLarge 4K Co: 0.370 ms
PaintLionLarge 4K PreClip: 1.894 ms
PaintLionLarge 4K PreClip Co: 0.406 ms
PaintLionLarge 4K Cleared: 2.793 ms
PaintLionLarge 4K Cleared Co: 1.094 ms
PaintLionLarge 4K Cleared PreClip: 2.762 ms
PaintLionLarge 4K Cleared PreClip Co: 1.048 ms
OLD:
PaintLionLarge 1K: 0.825 ms
PaintLionLarge 1K Co: 0.232 ms
PaintLionLarge 1K PreClip: 0.845 ms
PaintLionLarge 1K PreClip Co: 0.211 ms
PaintLionLarge 1K Cleared: 0.850 ms
PaintLionLarge 1K Cleared Co: 0.296 ms
PaintLionLarge 1K Cleared PreClip: 0.833 ms
PaintLionLarge 1K Cleared PreClip Co: 0.290 ms
PaintLionLarge 4K: 2.008 ms
PaintLionLarge 4K Co: 0.408 ms
PaintLionLarge 4K PreClip: 2.024 ms
PaintLionLarge 4K PreClip Co: 0.383 ms
PaintLionLarge 4K Cleared: 2.717 ms
PaintLionLarge 4K Cleared Co: 1.087 ms
PaintLionLarge 4K Cleared PreClip: 2.778 ms
PaintLionLarge 4K Cleared PreClip Co: 0.965 ms

View file

@ -183,11 +183,13 @@ void PaintLion(Painter& sw)
for(int i = 0; i < l.GetCount(); i++) {
Vector<Pointf>& p = l[i].point;
sw.Move(p[0]);
for(int j = 1; j < p.GetCount(); j++) {
// RTIMING("Line");
for(int j = 1; j < p.GetCount(); j++)
sw.Line(p[j]);
}
// sw.Stroke(2, l[i].color);
sw.Fill(l[i].color);
}
}
void PaintLionLarge(Painter& sw) {
sw.Scale(3);
PaintLion(sw);
}

View file

@ -0,0 +1,131 @@
#include "LionBenchmark.h"
Tuple<const char *, void (*)(Painter& sw)> tasks[] =
{
#define TASK(x) { #x, x, }
TASK(PaintLionLarge),
#if 0
TASK(PaintLion),
TASK(TextRotated),
TASK(PythagorasTree),
TASK(Demo),
TASK(ClippingExample),
TASK(PolyPolygon),
TASK(TextOnPath),
TASK(Dash),
TASK(SomeRocks),
#endif
};
void Task(Painter& sw, int i)
{
RTIMING("Total");
sw.Begin();
// sw.Scale(1.2);
// sw.Opacity(0.3);
// sw.Translate(20, 0);
// sw.Rotate(0.1);
(*tasks[clamp(i, 0, __countof(tasks) - 1)].b)(sw);
sw.End();
}
double tm[__countof(tasks)][16];
String FormatOpts(int pass)
{
String r = pass & 8 ? "4K" : "1K";
if(pass & 4)
r << " Cleared";
if(pass & 2)
r << " PreClip";
if(pass & 1)
r << " Co";
r << ": ";
return r;
}
String FormatPass(int pass, double tm)
{
return FormatOpts(pass) << Format("%.3f ms", tm);
}
struct MyApp : public TopWindow {
bool co = true;
DropList task;
virtual void LeftDown(Point p, dword keyflags)
{
co = !co;
Refresh();
}
virtual void Paint(Draw& w) {
w.DrawRect(GetSize(), White());
for(int pass = 0; pass < 2; pass++) {
ImageBuffer ib(1200, 800);
{
BufferPainter sw(ib);
if(pass)
sw.Co();
sw.PreClip();
sw.Clear(White());
Task(sw, ~task);
}
w.DrawImage(0, 800 * pass, ib);
}
int x = 1200;
int y = 0;
int lcy = StdFont().GetCy();
for(int i = 0; i < 16; i++) {
w.DrawText(x, y += lcy, FormatPass(i, tm[~task][i]));
if((i & 3) == 3)
y += lcy / 2;
}
}
MyApp() {
for(int i = 0; i < __countof(tasks); i++)
task.Add(i, tasks[i].a);
task << [=] { Refresh(); };
Add(task.RightPosZ(8, 200).TopPosZ(8));
task <<= 0;
}
};
GUI_APP_MAIN
{
#ifdef _DEBUG
int duration = 100;
#else
int duration = 500;
#endif
Progress pi("Tasks", 16 * __countof(tasks));
for(int ti = 0; ti < __countof(tasks); ti++) {
pi.SetText(tasks[ti].a);
for(int pass = 0; pass < 16; pass++) {
if(pi.StepCanceled())
return;
int time0 = msecs();
int n = 0;
int sz = pass & 8 ? 2048 : 512;
ImageBuffer ib(sz, sz);
{
BufferPainter sw(ib);
sw.Co(pass & 1);
sw.PreClip(pass & 2);
while(msecs(time0) < duration) {
n++;
if(pass & 4)
sw.Clear(White());
Task(sw, ti);
}
}
tm[ti][pass] = (double)msecs(time0) / n;
RLOG(tasks[ti].a << " " << FormatPass(pass, tm[ti][pass]));
}
RLOG("========");
}
MyApp().Run();
}

View file

@ -1,9 +0,0 @@
uses
CtrlLib;
file
main.cpp;
mainconfig
"" = "GUI";

View file

@ -1,41 +0,0 @@
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
void CoFill(RGBA *t, RGBA c, int len)
{
const int CHUNK = 1024;
std::atomic<int> ii(0);
CoDo([&] {
for(;;) {
int pos = CHUNK * ii++;
if(pos >= len)
break;
Fill(t + pos, c, min(CHUNK, len - pos));
}
});
}
GUI_APP_MAIN
{
Color c = Red();
int len = 4000 * 2000;
Buffer<RGBA> b(len);
for(int i = 0; i < 10; i++) {
{
RTIMING("memsetd");
memsetd(b, *(dword*)&(c), len);
}
{
RTIMING("Fill");
Fill(b, c, len);
}
{
RTIMING("CoFill");
CoFill(b, c, len);
}
}
}