2 * Copyright (C) 2008-2009 Stephan Aßmus <superstippi@gmx.de>
3 * All rights reserved. Distributed under the terms of the MIT license.
6 #include "HorizontalLineTest.h"
12 #include "TestSupport.h"
15 HorizontalLineTest::HorizontalLineTest()
25 fViewBounds(0, 0, -1, -1)
30 HorizontalLineTest::~HorizontalLineTest()
36 HorizontalLineTest::Prepare(BView
* view
)
38 fViewBounds
= view
->Bounds();
43 fTestStart
= system_time();
47 HorizontalLineTest::RunIteration(BView
* view
)
51 bigtime_t now
= system_time();
54 view
->StrokeLine(BPoint(fViewBounds
.left
+ 1, y
),
55 BPoint(fViewBounds
.right
- 1, y
));
59 // offset text location
61 if (y
> fViewBounds
.bottom
)
67 fTestDuration
+= system_time() - now
;
70 return fIterations
< fMaxIterations
;
75 HorizontalLineTest::PrintResults(BView
* view
)
77 if (fTestDuration
== 0) {
78 printf("Test was not run.\n");
81 bigtime_t timeLeak
= system_time() - fTestStart
- fTestDuration
;
83 Test::PrintResults(view
);
85 printf("Line width: %ld\n", fViewBounds
.IntegerWidth() + 1 - 2);
86 printf("Lines per iteration: %ld\n", fViewBounds
.IntegerHeight() / 2);
87 printf("Total lines rendered: %llu\n", fLinesRendered
);
88 printf("Lines per second: %.3f\n",
89 fLinesRendered
* 1000000.0 / fTestDuration
);
90 printf("Average time between iterations: %.4f seconds.\n",
91 (float)timeLeak
/ fIterations
/ 1000000);
96 HorizontalLineTest::CreateTest()
98 return new HorizontalLineTest();