* Added a SetupClipping() method to Test baseclass, which adds about 400

small clipping holes to the TestView user clipping.
* Added a bunch of new tests. Here are some numbers from the test environment,
  which is similar to running Haiku in VESA mode:

Horizontal lines per second:
Haiku:	192964.663	(117,7%)
ZETA:	163977.006

Vertical lines per second:
Haiku:	 90109.985	(276.9%)
ZETA:	 32538.458

Random lines per second:
Haiku:	  7998.451	(23.1%)
ZETA:	 34602.539

Random colored lines per second:
Haiku:	  7976.437	(22.9%)
ZETA:	 34788.247

Random clipped lines per second:
Haiku:	   262.180	(2.5%)
ZETA:	 10394.794

Clipped glyphs per second:
Haiku:	  5911.526	(1.0%)
ZETA:	590508.726

Obviously the clipping performance is a punch in the stomache.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26683 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2008-07-29 21:12:48 +00:00
parent 7b0cfaa569
commit b4e9c99bc4
15 changed files with 541 additions and 1 deletions
@@ -11,13 +11,21 @@
#include "TestWindow.h"
// tests
#include "ClippedLineTest.h"
#include "HorizontalLineTest.h"
#include "RandomLineTest.h"
#include "StringTest.h"
#include "VerticalLineTest.h"
class Benchmark : public BApplication {
public:
Benchmark()
: BApplication("application/x-vnd.haiku-benchmark"),
fTest(new StringTest),
fTest(new ClippedLineTest),
// fTest(new HorizontalLineTest),
// fTest(new RandomLineTest),
// fTest(new StringTest),
// fTest(new VerticalLineTest),
fTestWindow(NULL)
{
}
@@ -0,0 +1,95 @@
/*
* Copyright (C) 2008 Stephan Aßmus <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "ClippedLineTest.h"
#include <stdio.h>
#include <Region.h>
#include <View.h>
#include "TestSupport.h"
ClippedLineTest::ClippedLineTest()
: Test(),
fTestDuration(0),
fTestStart(-1),
fLinesRendered(0),
fLinesPerIteration(20),
fIterations(0),
fMaxIterations(100),
fViewBounds(0, 0, -1, -1)
{
}
ClippedLineTest::~ClippedLineTest()
{
}
void
ClippedLineTest::Prepare(BView* view)
{
fViewBounds = view->Bounds();
SetupClipping(view);
fTestDuration = 0;
fLinesRendered = 0;
fIterations = 0;
fTestStart = system_time();
}
bool
ClippedLineTest::RunIteration(BView* view)
{
bigtime_t now = system_time();
float vMiddle = (fViewBounds.top + fViewBounds.bottom) / 2;
for (uint32 i = 0; i < fLinesPerIteration; i++) {
view->SetHighColor(rand() % 255, rand() % 255, rand() % 255);
BPoint a;
a.x = random_number_between(fViewBounds.left, fViewBounds.right);
a.y = random_number_between(fViewBounds.top, vMiddle);
BPoint b;
b.x = random_number_between(fViewBounds.left, fViewBounds.right);
b.y = random_number_between(vMiddle, fViewBounds.bottom);
view->StrokeLine(a, b);
fLinesRendered++;
}
view->Sync();
fTestDuration += system_time() - now;
fIterations++;
return fIterations < fMaxIterations;
}
void
ClippedLineTest::PrintResults()
{
if (fTestDuration == 0) {
printf("Test was not run.\n");
return;
}
bigtime_t timeLeak = system_time() - fTestStart - fTestDuration;
printf("Lines per iteration: %lu\n", fLinesPerIteration);
printf("Lines per second: %.3f\n",
fLinesRendered * 1000000.0 / fTestDuration);
printf("Average time between iterations: %.4f seconds.\n",
(float)timeLeak / fIterations / 1000000);
}
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2008 Stephan Aßmus <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef CLIPPED_LINE_TEST_H
#define CLIPPED_LINE_TEST_H
#include <Rect.h>
#include "Test.h"
class ClippedLineTest : public Test {
public:
ClippedLineTest();
virtual ~ClippedLineTest();
virtual void Prepare(BView* view);
virtual bool RunIteration(BView* view);
virtual void PrintResults();
private:
bigtime_t fTestDuration;
bigtime_t fTestStart;
uint64 fLinesRendered;
uint32 fLinesPerIteration;
uint32 fIterations;
uint32 fMaxIterations;
BRect fViewBounds;
};
#endif // CLIPPED_LINE_TEST_H
@@ -0,0 +1,89 @@
/*
* Copyright (C) 2008 Stephan Aßmus <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "HorizontalLineTest.h"
#include <stdio.h>
#include <View.h>
#include "TestSupport.h"
HorizontalLineTest::HorizontalLineTest()
: Test(),
fTestDuration(0),
fTestStart(-1),
fLinesRendered(0),
fIterations(0),
fMaxIterations(1500),
fViewBounds(0, 0, -1, -1)
{
}
HorizontalLineTest::~HorizontalLineTest()
{
}
void
HorizontalLineTest::Prepare(BView* view)
{
fViewBounds = view->Bounds();
fTestDuration = 0;
fLinesRendered = 0;
fIterations = 0;
fTestStart = system_time();
}
bool
HorizontalLineTest::RunIteration(BView* view)
{
float y = 1;
bigtime_t now = system_time();
while (true) {
view->StrokeLine(BPoint(fViewBounds.left + 1, y),
BPoint(fViewBounds.right - 1, y));
fLinesRendered++;
// offset text location
y += 2;
if (y > fViewBounds.bottom)
break;
}
view->Sync();
fTestDuration += system_time() - now;
fIterations++;
return fIterations < fMaxIterations;
}
void
HorizontalLineTest::PrintResults()
{
if (fTestDuration == 0) {
printf("Test was not run.\n");
return;
}
bigtime_t timeLeak = system_time() - fTestStart - fTestDuration;
printf("Line width: %ld\n", fViewBounds.IntegerWidth() + 1 - 2);
printf("Lines per iteration: %ld\n", fViewBounds.IntegerHeight() / 2);
printf("Lines per second: %.3f\n",
fLinesRendered * 1000000.0 / fTestDuration);
printf("Average time between iterations: %.4f seconds.\n",
(float)timeLeak / fIterations / 1000000);
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2008 Stephan Aßmus <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef HORIZONTAL_LINE_TEST_H
#define HORIZONTAL_LINE_TEST_H
#include <Rect.h>
#include "Test.h"
class HorizontalLineTest : public Test {
public:
HorizontalLineTest();
virtual ~HorizontalLineTest();
virtual void Prepare(BView* view);
virtual bool RunIteration(BView* view);
virtual void PrintResults();
private:
bigtime_t fTestDuration;
bigtime_t fTestStart;
uint64 fLinesRendered;
uint32 fIterations;
uint32 fMaxIterations;
BRect fViewBounds;
};
#endif // HORIZONTAL_LINE_TEST_H
+4
View File
@@ -8,9 +8,13 @@ UseHeaders [ FDirName os interface ] ;
Application Benchmark :
Benchmark.cpp
ClippedLineTest.cpp
HorizontalLineTest.cpp
RandomLineTest.cpp
StringTest.cpp
Test.cpp
TestWindow.cpp
VerticalLineTest.cpp
: be
;
@@ -0,0 +1,92 @@
/*
* Copyright (C) 2008 Stephan Aßmus <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "RandomLineTest.h"
#include <stdio.h>
#include <View.h>
#include "TestSupport.h"
RandomLineTest::RandomLineTest()
: Test(),
fTestDuration(0),
fTestStart(-1),
fLinesRendered(0),
fLinesPerIteration(100),
fIterations(0),
fMaxIterations(1500),
fViewBounds(0, 0, -1, -1)
{
}
RandomLineTest::~RandomLineTest()
{
}
void
RandomLineTest::Prepare(BView* view)
{
fViewBounds = view->Bounds();
fTestDuration = 0;
fLinesRendered = 0;
fIterations = 0;
fTestStart = system_time();
}
bool
RandomLineTest::RunIteration(BView* view)
{
bigtime_t now = system_time();
float vMiddle = (fViewBounds.top + fViewBounds.bottom) / 2;
for (uint32 i = 0; i < fLinesPerIteration; i++) {
view->SetHighColor(rand() % 255, rand() % 255, rand() % 255);
BPoint a;
a.x = random_number_between(fViewBounds.left, fViewBounds.right);
a.y = random_number_between(fViewBounds.top, vMiddle);
BPoint b;
b.x = random_number_between(fViewBounds.left, fViewBounds.right);
b.y = random_number_between(vMiddle, fViewBounds.bottom);
view->StrokeLine(a, b);
fLinesRendered++;
}
view->Sync();
fTestDuration += system_time() - now;
fIterations++;
return fIterations < fMaxIterations;
}
void
RandomLineTest::PrintResults()
{
if (fTestDuration == 0) {
printf("Test was not run.\n");
return;
}
bigtime_t timeLeak = system_time() - fTestStart - fTestDuration;
printf("Lines per iteration: %lu\n", fLinesPerIteration);
printf("Lines per second: %.3f\n",
fLinesRendered * 1000000.0 / fTestDuration);
printf("Average time between iterations: %.4f seconds.\n",
(float)timeLeak / fIterations / 1000000);
}
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2008 Stephan Aßmus <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef VERTICAL_LINE_TEST_H
#define VERTICAL_LINE_TEST_H
#include <Rect.h>
#include "Test.h"
class RandomLineTest : public Test {
public:
RandomLineTest();
virtual ~RandomLineTest();
virtual void Prepare(BView* view);
virtual bool RunIteration(BView* view);
virtual void PrintResults();
private:
bigtime_t fTestDuration;
bigtime_t fTestStart;
uint64 fLinesRendered;
uint32 fLinesPerIteration;
uint32 fIterations;
uint32 fMaxIterations;
BRect fViewBounds;
};
#endif // VERTICAL_LINE_TEST_H
@@ -36,6 +36,8 @@ StringTest::~StringTest()
void
StringTest::Prepare(BView* view)
{
// SetupClipping(view);
font_height fh;
view->GetFontHeight(&fh);
fLineHeight = ceilf(fh.ascent) + ceilf(fh.descent)
+22
View File
@@ -5,6 +5,9 @@
#include "Test.h"
#include <Region.h>
#include <View.h>
Test::Test()
{
@@ -14,3 +17,22 @@ Test::Test()
Test::~Test()
{
}
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) {
BRect r(x, y, x, y);
r.InsetBy(-5, -5);
clipping.Exclude(r);
}
}
view->ConstrainClippingRegion(&clipping);
}
+2
View File
@@ -15,6 +15,8 @@ public:
virtual void Prepare(BView* view) = 0;
virtual bool RunIteration(BView* view) = 0;
virtual void PrintResults() = 0;
void SetupClipping(BView* view);
};
#endif // TEST_H
@@ -14,6 +14,12 @@ TestView::TestView(BRect frame, Test* test, drawing_mode mode,
fTarget(target)
{
SetDrawingMode(mode);
}
void
TestView::AttachedToWindow()
{
fTest->Prepare(this);
}
@@ -25,6 +25,7 @@ public:
drawing_mode mode,
const BMessenger& target);
virtual void AttachedToWindow();
virtual void Draw(BRect updateRect);
private:
@@ -0,0 +1,89 @@
/*
* Copyright (C) 2008 Stephan Aßmus <[email protected]>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#include "VerticalLineTest.h"
#include <stdio.h>
#include <View.h>
#include "TestSupport.h"
VerticalLineTest::VerticalLineTest()
: Test(),
fTestDuration(0),
fTestStart(-1),
fLinesRendered(0),
fIterations(0),
fMaxIterations(1500),
fViewBounds(0, 0, -1, -1)
{
}
VerticalLineTest::~VerticalLineTest()
{
}
void
VerticalLineTest::Prepare(BView* view)
{
fViewBounds = view->Bounds();
fTestDuration = 0;
fLinesRendered = 0;
fIterations = 0;
fTestStart = system_time();
}
bool
VerticalLineTest::RunIteration(BView* view)
{
float x = 1;
bigtime_t now = system_time();
while (true) {
view->StrokeLine(BPoint(x, fViewBounds.top + 1),
BPoint(x, fViewBounds.bottom - 1));
fLinesRendered++;
// offset text location
x += 2;
if (x > fViewBounds.right)
break;
}
view->Sync();
fTestDuration += system_time() - now;
fIterations++;
return fIterations < fMaxIterations;
}
void
VerticalLineTest::PrintResults()
{
if (fTestDuration == 0) {
printf("Test was not run.\n");
return;
}
bigtime_t timeLeak = system_time() - fTestStart - fTestDuration;
printf("Line height: %ld\n", fViewBounds.IntegerHeight() + 1 - 2);
printf("Lines per iteration: %ld\n", fViewBounds.IntegerWidth() / 2);
printf("Lines per second: %.3f\n",
fLinesRendered * 1000000.0 / fTestDuration);
printf("Average time between iterations: %.4f seconds.\n",
(float)timeLeak / fIterations / 1000000);
}
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2008 Stephan Aßmus <superstippi@gmx.de>
* All rights reserved. Distributed under the terms of the MIT license.
*/
#ifndef VERTICAL_LINE_TEST_H
#define VERTICAL_LINE_TEST_H
#include <Rect.h>
#include "Test.h"
class VerticalLineTest : public Test {
public:
VerticalLineTest();
virtual ~VerticalLineTest();
virtual void Prepare(BView* view);
virtual bool RunIteration(BView* view);
virtual void PrintResults();
private:
bigtime_t fTestDuration;
bigtime_t fTestStart;
uint64 fLinesRendered;
uint32 fIterations;
uint32 fMaxIterations;
BRect fViewBounds;
};
#endif // VERTICAL_LINE_TEST_H