blob: 79e1036c527294e871f24ebbc79e178da2f6ffa2 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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.combe9ad4e2011-06-07 19:16:02 +00008#ifndef SkBenchTimer_DEFINED
9#define SkBenchTimer_DEFINED
10
bsalomon@google.com373a6632011-10-19 20:43:20 +000011#include <SkTypes.h>
12
13
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000014class BenchSysTimer;
15class BenchGpuTimer;
16
robertphillips@google.com6177e692013-02-28 20:16:25 +000017class SkGLContextHelper;
bsalomon@google.com373a6632011-10-19 20:43:20 +000018
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000019/**
20 * SysTimers and GpuTimers are implemented orthogonally.
robertphillips@google.com91ee3a12012-08-28 12:18:40 +000021 * 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.combe9ad4e2011-06-07 19:16:02 +000027 */
28class BenchTimer {
29public:
robertphillips@google.com6177e692013-02-28 20:16:25 +000030 BenchTimer(SkGLContextHelper* gl = NULL);
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000031 ~BenchTimer();
32 void start();
33 void end();
robertphillips@google.com91ee3a12012-08-28 12:18:40 +000034 void truncatedEnd();
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000035 double fCpu;
36 double fWall;
robertphillips@google.com91ee3a12012-08-28 12:18:40 +000037 double fTruncatedCpu;
38 double fTruncatedWall;
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000039 double fGpu;
rmistry@google.comfbfcd562012-08-23 18:09:54 +000040
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000041private:
42 BenchSysTimer *fSysTimer;
robertphillips@google.com91ee3a12012-08-28 12:18:40 +000043 BenchSysTimer *fTruncatedSysTimer;
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000044#if SK_SUPPORT_GPU
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000045 BenchGpuTimer *fGpuTimer;
bsalomon@google.comcf8fb1f2012-08-02 14:03:32 +000046#endif
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000047};
48
49#endif