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

Side by Side Diff: client/deps/glbench/src/bench.cc

Issue 2115012: Added texture update test. (Closed) Base URL: ssh://git@chromiumos-git//autotest.git
Patch Set: C++ enum 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/all_tests.h ('k') | client/deps/glbench/src/main.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 #include "main.h"
6 #include "testbase.h"
7
8 uint64_t TimeTest(glbench::TestBase* test, int iter) {
9 SwapBuffers();
10 glFinish();
11 uint64_t time1 = GetUTime();
12 test->TestFunc(iter);
13 glFinish();
14 uint64_t time2 = GetUTime();
15 return time2 - time1;
16 }
17
18 // Benchmark some draw commands, by running it many times.
19 // We want to measure the marginal cost, so we try more and more iterations
20 // until we get a somewhat linear response (to eliminate constant cost), and we
21 // do a linear regression on a few samples.
22 bool Bench(glbench::TestBase* test, float *slope, int64_t *bias) {
23 // Do one iteration in case the driver needs to set up states.
24 if (TimeTest(test, 1) > MAX_ITERATION_DURATION_MS)
25 return false;
26 int64_t count = 0;
27 int64_t sum_x = 0;
28 int64_t sum_y = 0;
29 int64_t sum_xy = 0;
30 int64_t sum_x2 = 0;
31 uint64_t last_time = 0;
32 bool do_count = false;
33 uint64_t iter;
34 for (iter = 8; iter < 1<<30; iter *= 2) {
35 uint64_t time = TimeTest(test, iter);
36 if (last_time > 0 && (time > last_time * 1.8))
37 do_count = true;
38 last_time = time;
39 if (do_count) {
40 ++count;
41 sum_x += iter;
42 sum_y += time;
43 sum_xy += iter * time;
44 sum_x2 += iter * iter;
45 }
46 if ((time >= 500000 && count > 4))
47 break;
48 }
49 if (count < 2) {
50 *slope = 0.f;
51 *bias = 0;
52 }
53 *slope = static_cast<float>(sum_x * sum_y - count * sum_xy) /
54 (sum_x * sum_x - count * sum_x2);
55 *bias = (sum_x * sum_xy - sum_x2 * sum_y) / (sum_x * sum_x - count * sum_x2);
56 return true;
57 }
OLDNEW
« no previous file with comments | « client/deps/glbench/src/all_tests.h ('k') | client/deps/glbench/src/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698