From 87b8310c0f8e8854a9fe696959fdc6d048d60206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 30 Jul 2008 11:40:18 +0000 Subject: [PATCH] The ClippedLineTest now runs for 5 seconds max (should change the other tests accordingly and refactor a bit). It also prints the number of clipping rects. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26685 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../servers/app/benchmark/ClippedLineTest.cpp | 6 ++++-- .../servers/app/benchmark/ClippedLineTest.h | 2 +- src/tests/servers/app/benchmark/Test.cpp | 17 ++++++++--------- src/tests/servers/app/benchmark/Test.h | 5 +++++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/tests/servers/app/benchmark/ClippedLineTest.cpp b/src/tests/servers/app/benchmark/ClippedLineTest.cpp index d651e96c6c..431699a19c 100644 --- a/src/tests/servers/app/benchmark/ClippedLineTest.cpp +++ b/src/tests/servers/app/benchmark/ClippedLineTest.cpp @@ -22,7 +22,7 @@ ClippedLineTest::ClippedLineTest() fLinesPerIteration(20), fIterations(0), - fMaxIterations(100), + fMaxTestDuration(5000000), fViewBounds(0, 0, -1, -1) { @@ -74,7 +74,7 @@ ClippedLineTest::RunIteration(BView* view) fTestDuration += system_time() - now; fIterations++; - return fIterations < fMaxIterations; + return system_time() - fTestStart < fMaxTestDuration; } @@ -87,6 +87,8 @@ ClippedLineTest::PrintResults() } bigtime_t timeLeak = system_time() - fTestStart - fTestDuration; printf("Lines per iteration: %lu\n", fLinesPerIteration); + printf("Clipping rects: %ld\n", fClippingRegion.CountRects()); + printf("Total lines rendered: %llu\n", fLinesRendered); printf("Lines per second: %.3f\n", fLinesRendered * 1000000.0 / fTestDuration); printf("Average time between iterations: %.4f seconds.\n", diff --git a/src/tests/servers/app/benchmark/ClippedLineTest.h b/src/tests/servers/app/benchmark/ClippedLineTest.h index 27a960aeef..878120efe5 100644 --- a/src/tests/servers/app/benchmark/ClippedLineTest.h +++ b/src/tests/servers/app/benchmark/ClippedLineTest.h @@ -25,7 +25,7 @@ private: uint32 fLinesPerIteration; uint32 fIterations; - uint32 fMaxIterations; + bigtime_t fMaxTestDuration; BRect fViewBounds; }; diff --git a/src/tests/servers/app/benchmark/Test.cpp b/src/tests/servers/app/benchmark/Test.cpp index 3b1474633f..a67dc6e4c7 100644 --- a/src/tests/servers/app/benchmark/Test.cpp +++ b/src/tests/servers/app/benchmark/Test.cpp @@ -5,7 +5,6 @@ #include "Test.h" -#include #include @@ -23,16 +22,16 @@ void Test::SetupClipping(BView* view) { BRect bounds = view->Bounds(); - BRegion clipping(bounds); - BRect grid(bounds.InsetByCopy(10, 10)); - for (float y = grid.top; y < grid.bottom - 5; y += grid.Height() / 20) { - for (float x = grid.left; x < grid.right - 5; - x += grid.Width() / 20) { + fClippingRegion.Set(bounds); + BRect grid(bounds.InsetByCopy(40, 40)); + for (float y = grid.top; y < grid.bottom + 5; y += grid.Height() / 2) { + for (float x = grid.left; x < grid.right + 5; + x += grid.Width() / 2) { BRect r(x, y, x, y); - r.InsetBy(-5, -5); - clipping.Exclude(r); + r.InsetBy(-30, -30); + fClippingRegion.Exclude(r); } } - view->ConstrainClippingRegion(&clipping); + view->ConstrainClippingRegion(&fClippingRegion); } diff --git a/src/tests/servers/app/benchmark/Test.h b/src/tests/servers/app/benchmark/Test.h index faca7b3cc0..8bb295b49b 100644 --- a/src/tests/servers/app/benchmark/Test.h +++ b/src/tests/servers/app/benchmark/Test.h @@ -5,6 +5,8 @@ #ifndef TEST_H #define TEST_H +#include + class BView; class Test { @@ -17,6 +19,9 @@ public: virtual void PrintResults() = 0; void SetupClipping(BView* view); + +protected: + BRegion fClippingRegion; }; #endif // TEST_H