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 "VerticalLineTest.h"
12 #include "TestSupport.h"
15 VerticalLineTest::VerticalLineTest()
25 fViewBounds(0, 0, -1, -1)
30 VerticalLineTest::~VerticalLineTest()
36 VerticalLineTest::Prepare(BView
* view
)
38 fViewBounds
= view
->Bounds();
43 fTestStart
= system_time();
47 VerticalLineTest::RunIteration(BView
* view
)
51 bigtime_t now
= system_time();
54 view
->StrokeLine(BPoint(x
, fViewBounds
.top
+ 1),
55 BPoint(x
, fViewBounds
.bottom
- 1));
59 // offset text location
61 if (x
> fViewBounds
.right
)
67 fTestDuration
+= system_time() - now
;
70 return fIterations
< fMaxIterations
;
75 VerticalLineTest::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 height: %ld\n", fViewBounds
.IntegerHeight() + 1 - 2);
86 printf("Lines per iteration: %ld\n", fViewBounds
.IntegerWidth() / 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 VerticalLineTest::CreateTest()
98 return new VerticalLineTest();