blob: 09950a734be956934c96de59c233186a3c4293ca [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();
reed@google.comef77ec22013-05-29 15:39:54 +000032 void start(double durationScale = 1);
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000033 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
reed@google.comef77ec22013-05-29 15:39:54 +000047 double fDurationScale; // for this start/end session
bungeman@google.combe9ad4e2011-06-07 19:16:02 +000048};
49
50#endif