| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include "testbase.h" | 7 #include "testbase.h" |
| 8 | 8 |
| 9 namespace glbench { | 9 namespace glbench { |
| 10 | 10 |
| 11 uint64_t TimeTest(TestBase* test, int iter) { | 11 uint64_t TimeTest(TestBase* test, int iter) { |
| 12 SwapBuffers(); | 12 SwapBuffers(); |
| 13 glFinish(); | 13 glFinish(); |
| 14 uint64_t time1 = GetUTime(); | 14 uint64_t time1 = GetUTime(); |
| 15 test->TestFunc(iter); | 15 if (!test->TestFunc(iter)) |
| 16 return ~0; |
| 16 glFinish(); | 17 glFinish(); |
| 17 uint64_t time2 = GetUTime(); | 18 uint64_t time2 = GetUTime(); |
| 18 return time2 - time1; | 19 return time2 - time1; |
| 19 } | 20 } |
| 20 | 21 |
| 21 #define MAX_ITERATION_DURATION_MS 100000 | 22 #define MAX_ITERATION_DURATION_MS 100000 |
| 22 | 23 |
| 23 // Benchmark some draw commands, by running it many times. | 24 // Benchmark some draw commands, by running it many times. |
| 24 // We want to measure the marginal cost, so we try more and more iterations | 25 // We want to measure the marginal cost, so we try more and more iterations |
| 25 // until we get a somewhat linear response (to eliminate constant cost), and we | 26 // until we get a somewhat linear response (to eliminate constant cost), and we |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bool DrawElementsTestFunc::TestFunc(int iter) { | 133 bool DrawElementsTestFunc::TestFunc(int iter) { |
| 133 glDrawElements(GL_TRIANGLES, count_, GL_UNSIGNED_INT, 0); | 134 glDrawElements(GL_TRIANGLES, count_, GL_UNSIGNED_INT, 0); |
| 134 glFlush(); | 135 glFlush(); |
| 135 for (int i = 0 ; i < iter-1; ++i) { | 136 for (int i = 0 ; i < iter-1; ++i) { |
| 136 glDrawElements(GL_TRIANGLES, count_, GL_UNSIGNED_INT, 0); | 137 glDrawElements(GL_TRIANGLES, count_, GL_UNSIGNED_INT, 0); |
| 137 } | 138 } |
| 138 return true; | 139 return true; |
| 139 } | 140 } |
| 140 | 141 |
| 141 } // namespace glbench | 142 } // namespace glbench |
| OLD | NEW |