epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2011 Google Inc. |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 8 | #ifndef SkBenchTimer_DEFINED |
| 9 | #define SkBenchTimer_DEFINED |
| 10 | |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 11 | #include <SkTypes.h> |
| 12 | |
| 13 | |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 14 | class BenchSysTimer; |
| 15 | class BenchGpuTimer; |
| 16 | |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 17 | class SkGLContextHelper; |
bsalomon@google.com | 373a663 | 2011-10-19 20:43:20 +0000 | [diff] [blame] | 18 | |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 19 | /** |
| 20 | * SysTimers and GpuTimers are implemented orthogonally. |
robertphillips@google.com | 91ee3a1 | 2012-08-28 12:18:40 +0000 | [diff] [blame] | 21 | * This class combines 2 SysTimers and a GpuTimer into one single, |
| 22 | * platform specific Timer with a simple interface. The truncated |
| 23 | * timer doesn't include the time required for the GPU to finish |
| 24 | * its rendering. It should always be <= the un-truncated system |
| 25 | * times and (for GPU configurations) can be used to roughly (very |
| 26 | * roughly) gauge the GPU load/backlog. |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 27 | */ |
| 28 | class BenchTimer { |
| 29 | public: |
robertphillips@google.com | 6177e69 | 2013-02-28 20:16:25 +0000 | [diff] [blame] | 30 | BenchTimer(SkGLContextHelper* gl = NULL); |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 31 | ~BenchTimer(); |
reed@google.com | ef77ec2 | 2013-05-29 15:39:54 +0000 | [diff] [blame] | 32 | void start(double durationScale = 1); |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 33 | void end(); |
robertphillips@google.com | 91ee3a1 | 2012-08-28 12:18:40 +0000 | [diff] [blame] | 34 | void truncatedEnd(); |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 35 | double fCpu; |
| 36 | double fWall; |
robertphillips@google.com | 91ee3a1 | 2012-08-28 12:18:40 +0000 | [diff] [blame] | 37 | double fTruncatedCpu; |
| 38 | double fTruncatedWall; |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 39 | double fGpu; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 40 | |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 41 | private: |
| 42 | BenchSysTimer *fSysTimer; |
robertphillips@google.com | 91ee3a1 | 2012-08-28 12:18:40 +0000 | [diff] [blame] | 43 | BenchSysTimer *fTruncatedSysTimer; |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 44 | #if SK_SUPPORT_GPU |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 45 | BenchGpuTimer *fGpuTimer; |
bsalomon@google.com | cf8fb1f | 2012-08-02 14:03:32 +0000 | [diff] [blame] | 46 | #endif |
reed@google.com | ef77ec2 | 2013-05-29 15:39:54 +0000 | [diff] [blame] | 47 | double fDurationScale; // for this start/end session |
bungeman@google.com | be9ad4e | 2011-06-07 19:16:02 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | #endif |