Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(560)

Side by Side Diff: client/deps/glbench/src/testbase.h

Issue 2123013: Split tests into individual files. Got rid of globals by converting them to classes. (Closed) Base URL: ssh://git@chromiumos-git//autotest.git
Patch Set: addressed comments Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « client/deps/glbench/src/teartest.cc ('k') | client/deps/glbench/src/testbase.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BENCH_GL_TESTBASE_H_
6 #define BENCH_GL_TESTBASE_H_
7
8 #include "base/basictypes.h"
9
10 #include "main.h"
11
12
13 namespace glbench {
14
15 class TestBase;
16
17 // Runs test->TestFunc() passing it sequential powers of two (8, 16, 32,...)
18 // recording time it took. The data is then fitted linearly, obtaining slope
19 // and bias such that:
20 // time it took to run x iterations = slope * x + bias
21 // Returns false if one iteration of the test takes longer than
22 // MAX_ITERATION_LENGTH_MS. The test is then assumed too slow to provide
23 // meaningful results.
24 bool Bench(TestBase* test, float *slope, int64_t *bias);
25
26 // Runs Bench on an instance of TestBase and prints out results.
27 //
28 // coefficient is multiplied (if inverse is false) or divided (if inverse is
29 // true) by the slope and the result is printed.
30 //
31 // Examples:
32 // coefficient = width * height (measured in pixels), inverse = true
33 // returns the throughput in megapixels per second;
34 //
35 // coefficient = 1, inverse = false
36 // returns number of operations per second.
37 void RunTest(TestBase* test, const char *name, float coefficient, bool inverse);
38
39
40 class TestBase {
41 public:
42 virtual ~TestBase() {}
43 // Runs the test case n times.
44 virtual bool TestFunc(int n) = 0;
45 // Main entry point into the test.
46 virtual bool Run() = 0;
47 };
48
49 // Helper class to time glDrawArrays.
50 class DrawArraysTestFunc : public TestBase {
51 public:
52 virtual ~DrawArraysTestFunc() {}
53 virtual bool TestFunc(int);
54
55 // Runs the test and reports results in mpixels per second, assuming each
56 // iteration updates the whole window (its size is g_width by g_height).
57 void FillRateTestNormal(const char* name);
58 // Runs the test and reports results in mpixels per second, assuming each
59 // iteration updates a window of width by height pixels.
60 void FillRateTestNormalSubWindow(const char* name, float width, float height);
61 #ifndef USE_EGL
62 // Runs the test three times: with blending on; with depth test enabled and
63 // depth function of GL_NOTEQUAL; with depth function GL_NEVER. Results are
64 // reported as in FillRateTestNormal.
65 void FillRateTestBlendDepth(const char *name);
66 #endif
67 };
68
69 // Helper class to time glDrawElements.
70 class DrawElementsTestFunc : public TestBase {
71 public:
72 DrawElementsTestFunc() : count_(0) {}
73 virtual ~DrawElementsTestFunc() {}
74 virtual bool TestFunc(int);
75
76 protected:
77 // Passed to glDrawElements.
78 GLsizei count_;
79 };
80
81 } // namespace glbench
82
83 #endif // BENCH_GL_TESTBASE_H_
OLDNEW
« no previous file with comments | « client/deps/glbench/src/teartest.cc ('k') | client/deps/glbench/src/testbase.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698