2011-07-28 14:26:00 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2011 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2011-06-07 19:16:02 +00:00
|
|
|
#ifndef SkBenchTimer_DEFINED
|
|
|
|
#define SkBenchTimer_DEFINED
|
|
|
|
|
2011-10-19 20:43:20 +00:00
|
|
|
#include <SkTypes.h>
|
|
|
|
|
|
|
|
|
2011-06-07 19:16:02 +00:00
|
|
|
class BenchSysTimer;
|
|
|
|
class BenchGpuTimer;
|
|
|
|
|
2013-02-28 20:16:25 +00:00
|
|
|
class SkGLContextHelper;
|
2011-10-19 20:43:20 +00:00
|
|
|
|
2011-06-07 19:16:02 +00:00
|
|
|
/**
|
|
|
|
* SysTimers and GpuTimers are implemented orthogonally.
|
2012-08-28 12:18:40 +00:00
|
|
|
* This class combines 2 SysTimers and a GpuTimer into one single,
|
|
|
|
* platform specific Timer with a simple interface. The truncated
|
|
|
|
* timer doesn't include the time required for the GPU to finish
|
|
|
|
* its rendering. It should always be <= the un-truncated system
|
|
|
|
* times and (for GPU configurations) can be used to roughly (very
|
|
|
|
* roughly) gauge the GPU load/backlog.
|
2011-06-07 19:16:02 +00:00
|
|
|
*/
|
|
|
|
class BenchTimer {
|
|
|
|
public:
|
2013-02-28 20:16:25 +00:00
|
|
|
BenchTimer(SkGLContextHelper* gl = NULL);
|
2011-06-07 19:16:02 +00:00
|
|
|
~BenchTimer();
|
2013-05-29 15:39:54 +00:00
|
|
|
void start(double durationScale = 1);
|
2011-06-07 19:16:02 +00:00
|
|
|
void end();
|
2012-08-28 12:18:40 +00:00
|
|
|
void truncatedEnd();
|
2011-06-07 19:16:02 +00:00
|
|
|
double fCpu;
|
|
|
|
double fWall;
|
2012-08-28 12:18:40 +00:00
|
|
|
double fTruncatedCpu;
|
|
|
|
double fTruncatedWall;
|
2011-06-07 19:16:02 +00:00
|
|
|
double fGpu;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2011-06-07 19:16:02 +00:00
|
|
|
private:
|
|
|
|
BenchSysTimer *fSysTimer;
|
2012-08-28 12:18:40 +00:00
|
|
|
BenchSysTimer *fTruncatedSysTimer;
|
2012-08-02 14:03:32 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2011-06-07 19:16:02 +00:00
|
|
|
BenchGpuTimer *fGpuTimer;
|
2012-08-02 14:03:32 +00:00
|
|
|
#endif
|
2013-05-29 15:39:54 +00:00
|
|
|
double fDurationScale; // for this start/end session
|
2011-06-07 19:16:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|