| 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 #ifndef BENCH_GL_MAIN_H_ | 5 #ifndef BENCH_GL_MAIN_H_ |
| 6 #define BENCH_GL_MAIN_H_ | 6 #define BENCH_GL_MAIN_H_ |
| 7 | 7 |
| 8 #include <gflags/gflags.h> | 8 #include <gflags/gflags.h> |
| 9 #include <sys/time.h> | 9 #include <sys/time.h> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 extern GLint g_width; | 59 extern GLint g_width; |
| 60 extern GLint g_height; | 60 extern GLint g_height; |
| 61 DECLARE_bool(override_redirect); | 61 DECLARE_bool(override_redirect); |
| 62 | 62 |
| 63 bool Init(); | 63 bool Init(); |
| 64 bool InitContext(); | 64 bool InitContext(); |
| 65 void DestroyContext(); | 65 void DestroyContext(); |
| 66 void SwapBuffers(); | 66 void SwapBuffers(); |
| 67 bool SwapInterval(int interval); | 67 bool SwapInterval(int interval); |
| 68 | 68 |
| 69 // BenchFunc functions are assumed to execute an operation iter times. See | |
| 70 // Bench for a detailed explanation. | |
| 71 typedef void (*BenchFunc)(int iter); | |
| 72 | |
| 73 uint64_t TimeBench(BenchFunc func, int iter); | |
| 74 | |
| 75 // This size is for a window that is very large but will fit on all | 69 // This size is for a window that is very large but will fit on all |
| 76 // the displays we care about. | 70 // the displays we care about. |
| 77 #define WINDOW_WIDTH 512 | 71 #define WINDOW_WIDTH 512 |
| 78 #define WINDOW_HEIGHT 512 | 72 #define WINDOW_HEIGHT 512 |
| 79 | 73 |
| 80 #define MAX_ITERATION_DURATION_MS 100000 | |
| 81 // Runs func passing it sequential powers of two (8, 16, 32,...) recording time | |
| 82 // it took. The data is then fitted linearly, obtaining slope and bias such | |
| 83 // that: | |
| 84 // time it took to run x iterations = slope * x + bias | |
| 85 // Returns false if one iteration of the test takes longer than | |
| 86 // MAX_ITERATION_LENGTH_MS. The test is then assumed too slow to provide | |
| 87 // meaningful results. | |
| 88 bool Bench(BenchFunc func, float *slope, int64_t *bias); | |
| 89 | |
| 90 void *MmapFile(const char *name, size_t *length); | |
| 91 | |
| 92 #endif // BENCH_GL_MAIN_H_ | 74 #endif // BENCH_GL_MAIN_H_ |
| OLD | NEW |