aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--bench/BenchGpuTimer_gl.cpp (renamed from tools/timer/GpuTimer.cpp)14
-rw-r--r--bench/BenchGpuTimer_gl.h (renamed from tools/timer/GpuTimer.h)15
-rw-r--r--bench/BenchSysTimer_c.cpp27
-rw-r--r--bench/BenchSysTimer_c.h26
-rw-r--r--bench/BenchSysTimer_mach.cpp (renamed from tools/timer/SysTimer_mach.cpp)54
-rw-r--r--bench/BenchSysTimer_mach.h (renamed from tools/timer/SysTimer_mach.h)8
-rw-r--r--bench/BenchSysTimer_posix.cpp (renamed from tools/timer/SysTimer_posix.cpp)36
-rw-r--r--bench/BenchSysTimer_posix.h (renamed from tools/timer/SysTimer_posix.h)8
-rw-r--r--bench/BenchSysTimer_windows.cpp (renamed from tools/timer/SysTimer_windows.cpp)34
-rw-r--r--bench/BenchSysTimer_windows.h (renamed from tools/timer/SysTimer_windows.h)7
-rw-r--r--bench/BenchTimer.cpp94
-rw-r--r--bench/BenchTimer.h (renamed from tools/timer/Timer.h)50
-rw-r--r--bench/TimerData.cpp (renamed from tools/timer/TimerData.cpp)24
-rw-r--r--bench/TimerData.h (renamed from tools/timer/TimerData.h)9
-rw-r--r--bench/benchmain.cpp6
-rw-r--r--debugger/QT/SkDebuggerGUI.cpp10
-rw-r--r--gyp/SampleApp.gyp2
-rw-r--r--gyp/apptype_console.gypi2
-rw-r--r--gyp/bench.gyp64
-rw-r--r--gyp/crash_handler.gyp18
-rw-r--r--gyp/debugger.gyp2
-rw-r--r--gyp/dm.gyp2
-rw-r--r--gyp/gm.gyp27
-rw-r--r--gyp/resources.gyp25
-rw-r--r--gyp/skia_launcher.gyp3
-rw-r--r--gyp/tests.gyp2
-rw-r--r--gyp/tests.gypi2
-rw-r--r--gyp/tools.gyp107
-rw-r--r--platform_tools/android/gyp/skia_android.gypi7
-rw-r--r--platform_tools/android/gyp/skia_launcher.gypi7
-rw-r--r--tools/DumpRecord.cpp4
-rw-r--r--tools/PictureBenchmark.cpp16
-rw-r--r--tools/PictureBenchmark.h4
-rw-r--r--tools/bbh_shootout.cpp8
-rw-r--r--tools/bench_pictures_main.cpp2
-rw-r--r--tools/bench_playback.cpp11
-rw-r--r--tools/bench_record.cpp22
-rw-r--r--tools/skpdiff/skpdiff_util.cpp2
-rw-r--r--tools/timer/Timer.cpp53
39 files changed, 495 insertions, 319 deletions
diff --git a/tools/timer/GpuTimer.cpp b/bench/BenchGpuTimer_gl.cpp
index 3174449f78..349fc1529d 100644
--- a/tools/timer/GpuTimer.cpp
+++ b/bench/BenchGpuTimer_gl.cpp
@@ -5,11 +5,11 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "GpuTimer.h"
+#include "BenchGpuTimer_gl.h"
#include "gl/SkGLContextHelper.h"
#include "gl/GrGLUtil.h"
-GpuTimer::GpuTimer(const SkGLContextHelper* glctx) {
+BenchGpuTimer::BenchGpuTimer(const SkGLContextHelper* glctx) {
fContext = glctx;
glctx->ref();
glctx->makeCurrent();
@@ -23,7 +23,7 @@ GpuTimer::GpuTimer(const SkGLContextHelper* glctx) {
}
}
-GpuTimer::~GpuTimer() {
+BenchGpuTimer::~BenchGpuTimer() {
if (fSupported) {
fContext->makeCurrent();
SK_GL(*fContext, DeleteQueries(1, &fQuery));
@@ -31,7 +31,7 @@ GpuTimer::~GpuTimer() {
fContext->unref();
}
-void GpuTimer::start() {
+void BenchGpuTimer::startGpu() {
if (fSupported) {
fContext->makeCurrent();
fStarted = true;
@@ -43,7 +43,7 @@ void GpuTimer::start() {
* It is important to stop the cpu clocks first,
* as this will cpu wait for the gpu to finish.
*/
-double GpuTimer::end() {
+double BenchGpuTimer::endGpu() {
if (fSupported) {
fStarted = false;
fContext->makeCurrent();
@@ -52,8 +52,8 @@ double GpuTimer::end() {
GrGLint available = 0;
while (!available) {
SK_GL_NOERRCHECK(*fContext, GetQueryObjectiv(fQuery,
- GR_GL_QUERY_RESULT_AVAILABLE,
- &available));
+ GR_GL_QUERY_RESULT_AVAILABLE,
+ &available));
// If GetQueryObjectiv is erroring out we need some alternative
// means of breaking out of this loop
GrGLenum error;
diff --git a/tools/timer/GpuTimer.h b/bench/BenchGpuTimer_gl.h
index 2100312a21..e472a4c514 100644
--- a/tools/timer/GpuTimer.h
+++ b/bench/BenchGpuTimer_gl.h
@@ -1,20 +1,21 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef GpuTimer_DEFINED
-#define GpuTimer_DEFINED
+#ifndef SkBenchGpuTimer_DEFINED
+#define SkBenchGpuTimer_DEFINED
class SkGLContextHelper;
-class GpuTimer {
+class BenchGpuTimer {
public:
- GpuTimer(const SkGLContextHelper*);
- ~GpuTimer();
- void start();
- double end();
+ BenchGpuTimer(const SkGLContextHelper* glctx);
+ ~BenchGpuTimer();
+ void startGpu();
+ double endGpu();
private:
unsigned fQuery;
int fStarted;
diff --git a/bench/BenchSysTimer_c.cpp b/bench/BenchSysTimer_c.cpp
new file mode 100644
index 0000000000..f4cbd39d73
--- /dev/null
+++ b/bench/BenchSysTimer_c.cpp
@@ -0,0 +1,27 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "BenchSysTimer_c.h"
+
+//Time
+#include <time.h>
+
+void BenchSysTimer::startWall() {
+ this->fStartWall = time();
+}
+void BenchSysTimer::startCpu() {
+ this->fStartCpu = clock();
+}
+
+double BenchSysTimer::endCpu() {
+ clock_t end_cpu = clock();
+ this->fCpu = (end_cpu - this->fStartCpu) * CLOCKS_PER_SEC / 1000.0;
+}
+double BenchSysTimer::endWall() {
+ time_t end_wall = time();
+ this->fWall = difftime(end_wall, this->fstartWall) / 1000.0;
+}
diff --git a/bench/BenchSysTimer_c.h b/bench/BenchSysTimer_c.h
new file mode 100644
index 0000000000..586f0b4ff0
--- /dev/null
+++ b/bench/BenchSysTimer_c.h
@@ -0,0 +1,26 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkBenchSysTimer_DEFINED
+#define SkBenchSysTimer_DEFINED
+
+//Time
+#include <time.h>
+
+// Beware: this timer uses standard (as opposed to high precision) clocks
+class BenchSysTimer {
+public:
+ void startWall();
+ void startCpu();
+ double endCpu();
+ double endWall();
+private:
+ clock_t start_cpu;
+ time_t fStartWall;
+};
+
+#endif
diff --git a/tools/timer/SysTimer_mach.cpp b/bench/BenchSysTimer_mach.cpp
index aca12dee52..1f0a6b9861 100644
--- a/tools/timer/SysTimer_mach.cpp
+++ b/bench/BenchSysTimer_mach.cpp
@@ -1,12 +1,17 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "SysTimer_mach.h"
+#include "BenchSysTimer_mach.h"
+
+//Time
+#include <mach/mach.h>
+#include <mach/mach_time.h>
-static time_value_t mac_cpu_time() {
+static time_value_t macCpuTime() {
mach_port_t task = mach_task_self();
if (task == MACH_PORT_NULL) {
time_value_t none = {0, 0};
@@ -16,9 +21,10 @@ static time_value_t mac_cpu_time() {
task_thread_times_info thread_info_data;
mach_msg_type_number_t thread_info_count = TASK_THREAD_TIMES_INFO_COUNT;
if (KERN_SUCCESS != task_info(task,
- TASK_THREAD_TIMES_INFO,
- reinterpret_cast<task_info_t>(&thread_info_data),
- &thread_info_count)) {
+ TASK_THREAD_TIMES_INFO,
+ reinterpret_cast<task_info_t>(&thread_info_data),
+ &thread_info_count))
+ {
time_value_t none = {0, 0};
return none;
}
@@ -27,40 +33,44 @@ static time_value_t mac_cpu_time() {
return thread_info_data.user_time;
}
-static double interval_in_ms(time_value_t start_clock, time_value_t end_clock) {
+static double intervalInMSec(const time_value_t start_clock
+ , const time_value_t end_clock)
+{
double duration_clock;
if ((end_clock.microseconds - start_clock.microseconds) < 0) {
- duration_clock = (end_clock.seconds - start_clock.seconds-1) * 1000;
- duration_clock += (1000000 + end_clock.microseconds - start_clock.microseconds) / 1000.0;
+ duration_clock = (end_clock.seconds - start_clock.seconds-1)*1000;
+ duration_clock += (1000000
+ + end_clock.microseconds
+ - start_clock.microseconds) / 1000.0;
} else {
- duration_clock = (end_clock.seconds - start_clock.seconds) * 1000;
- duration_clock += (end_clock.microseconds - start_clock.microseconds) / 1000.0;
+ duration_clock = (end_clock.seconds - start_clock.seconds)*1000;
+ duration_clock += (end_clock.microseconds - start_clock.microseconds)
+ / 1000.0;
}
return duration_clock;
}
-void SysTimer::startWall() {
- fStartWall = mach_absolute_time();
+void BenchSysTimer::startWall() {
+ this->fStartWall = mach_absolute_time();
}
-
-void SysTimer::startCpu() {
- fStartCpu = mac_cpu_time();
+void BenchSysTimer::startCpu() {
+ this->fStartCpu = macCpuTime();
}
-double SysTimer::endCpu() {
- time_value_t end_cpu = mac_cpu_time();
- return interval_in_ms(fStartCpu, end_cpu);
+double BenchSysTimer::endCpu() {
+ time_value_t end_cpu = macCpuTime();
+ return intervalInMSec(this->fStartCpu, end_cpu);
}
-
-double SysTimer::endWall() {
+double BenchSysTimer::endWall() {
uint64_t end_wall = mach_absolute_time();
- uint64_t elapsed = end_wall - fStartWall;
+ uint64_t elapsed = end_wall - this->fStartWall;
mach_timebase_info_data_t sTimebaseInfo;
if (KERN_SUCCESS != mach_timebase_info(&sTimebaseInfo)) {
return 0;
} else {
- uint64_t elapsedNano = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom;
+ uint64_t elapsedNano = elapsed * sTimebaseInfo.numer
+ / sTimebaseInfo.denom;
return elapsedNano / 1000000.0;
}
}
diff --git a/tools/timer/SysTimer_mach.h b/bench/BenchSysTimer_mach.h
index 8c21d57b36..44d0e5eb49 100644
--- a/tools/timer/SysTimer_mach.h
+++ b/bench/BenchSysTimer_mach.h
@@ -1,16 +1,18 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef SysTimer_DEFINED
-#define SysTimer_DEFINED
+#ifndef SkBenchSysTimer_DEFINED
+#define SkBenchSysTimer_DEFINED
+//Time
#include <mach/mach.h>
#include <mach/mach_time.h>
-class SysTimer {
+class BenchSysTimer {
public:
void startWall();
void startCpu();
diff --git a/tools/timer/SysTimer_posix.cpp b/bench/BenchSysTimer_posix.cpp
index 4b7d708aab..e6767e5af2 100644
--- a/tools/timer/SysTimer_posix.cpp
+++ b/bench/BenchSysTimer_posix.cpp
@@ -1,51 +1,57 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "SysTimer_posix.h"
+#include "BenchSysTimer_posix.h"
+
+//Time
+#include <time.h>
-static double interval_in_ms(timespec start_clock, timespec end_clock)
+static double intervalInMSec(const timespec start_clock
+ , const timespec end_clock)
{
double duration_clock;
if ((end_clock.tv_nsec - start_clock.tv_nsec) < 0) {
- duration_clock = (end_clock.tv_sec - start_clock.tv_sec - 1) * 1000;
- duration_clock += (1000000000 + end_clock.tv_nsec - start_clock.tv_nsec) / 1000000.0;
+ duration_clock = (end_clock.tv_sec - start_clock.tv_sec-1)*1000;
+ duration_clock += (1000000000 + end_clock.tv_nsec - start_clock.tv_nsec)
+ / 1000000.0;
} else {
- duration_clock = (end_clock.tv_sec - start_clock.tv_sec) * 1000;
+ duration_clock = (end_clock.tv_sec - start_clock.tv_sec)*1000;
duration_clock += (end_clock.tv_nsec - start_clock.tv_nsec) / 1000000.0;
}
return duration_clock;
}
-void SysTimer::startWall() {
- if (-1 == clock_gettime(CLOCK_MONOTONIC, &fWall)) {
+void BenchSysTimer::startWall() {
+ if (-1 == clock_gettime(CLOCK_MONOTONIC, &this->fWall)) {
timespec none = {0, 0};
- fWall = none;
+ this->fWall = none;
}
}
-void SysTimer::startCpu() {
- if (-1 == clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &fCpu)) {
+void BenchSysTimer::startCpu() {
+ if (-1 == clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &this->fCpu)) {
timespec none = {0, 0};
- fCpu = none;
+ this->fCpu = none;
}
}
-double SysTimer::endCpu() {
+double BenchSysTimer::endCpu() {
timespec end_cpu;
if (-1 == clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end_cpu)) {
timespec none = {0, 0};
end_cpu = none;
}
- return interval_in_ms(fCpu, end_cpu);
+ return intervalInMSec(this->fCpu, end_cpu);
}
-double SysTimer::endWall() {
+double BenchSysTimer::endWall() {
timespec end_wall;
if (-1 == clock_gettime(CLOCK_MONOTONIC, &end_wall)) {
timespec none = {0, 0};
end_wall = none;
}
- return interval_in_ms(fWall, end_wall);
+ return intervalInMSec(this->fWall, end_wall);
}
diff --git a/tools/timer/SysTimer_posix.h b/bench/BenchSysTimer_posix.h
index 1eca909e26..8fd97061b6 100644
--- a/tools/timer/SysTimer_posix.h
+++ b/bench/BenchSysTimer_posix.h
@@ -1,15 +1,17 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef SysTimer_DEFINED
-#define SysTimer_DEFINED
+#ifndef SkBenchSysTimer_DEFINED
+#define SkBenchSysTimer_DEFINED
+//Time
#include <time.h>
-class SysTimer {
+class BenchSysTimer {
public:
void startWall();
void startCpu();
diff --git a/tools/timer/SysTimer_windows.cpp b/bench/BenchSysTimer_windows.cpp
index 2f9d0a5d58..fab657a8c3 100644
--- a/tools/timer/SysTimer_windows.cpp
+++ b/bench/BenchSysTimer_windows.cpp
@@ -1,17 +1,25 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "SysTimer_windows.h"
+#include "BenchSysTimer_windows.h"
+
+//Time
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
-static ULONGLONG win_cpu_time() {
+static ULONGLONG winCpuTime() {
FILETIME createTime;
FILETIME exitTime;
FILETIME usrTime;
FILETIME sysTime;
- if (0 == GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &sysTime, &usrTime)) {
+ if (0 == GetProcessTimes(GetCurrentProcess()
+ , &createTime, &exitTime
+ , &sysTime, &usrTime))
+ {
return 0;
}
ULARGE_INTEGER start_cpu_sys;
@@ -23,27 +31,27 @@ static ULONGLONG win_cpu_time() {
return start_cpu_sys.QuadPart + start_cpu_usr.QuadPart;
}
-void SysTimer::startWall() {
- if (0 == ::QueryPerformanceCounter(&fStartWall)) {
- fStartWall.QuadPart = 0;
+void BenchSysTimer::startWall() {
+ if (0 == ::QueryPerformanceCounter(&this->fStartWall)) {
+ this->fStartWall.QuadPart = 0;
}
}
-void SysTimer::startCpu() {
- fStartCpu = win_cpu_time();
+void BenchSysTimer::startCpu() {
+ this->fStartCpu = winCpuTime();
}
-double SysTimer::endCpu() {
- ULONGLONG end_cpu = win_cpu_time();
- return static_cast<double>(end_cpu - fStartCpu) / 10000.0L;
+double BenchSysTimer::endCpu() {
+ ULONGLONG end_cpu = winCpuTime();
+ return static_cast<double>((end_cpu - this->fStartCpu)) / 10000.0L;
}
-double SysTimer::endWall() {
+double BenchSysTimer::endWall() {
LARGE_INTEGER end_wall;
if (0 == ::QueryPerformanceCounter(&end_wall)) {
end_wall.QuadPart = 0;
}
LARGE_INTEGER ticks_elapsed;
- ticks_elapsed.QuadPart = end_wall.QuadPart - fStartWall.QuadPart;
+ ticks_elapsed.QuadPart = end_wall.QuadPart - this->fStartWall.QuadPart;
LARGE_INTEGER frequency;
if (0 == ::QueryPerformanceFrequency(&frequency)) {
diff --git a/tools/timer/SysTimer_windows.h b/bench/BenchSysTimer_windows.h
index 62a9445134..469332e4ed 100644
--- a/tools/timer/SysTimer_windows.h
+++ b/bench/BenchSysTimer_windows.h
@@ -1,17 +1,18 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef SysTimer_DEFINED
-#define SysTimer_DEFINED
+#ifndef SkBenchSysTimer_DEFINED
+#define SkBenchSysTimer_DEFINED
//Time
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
-class SysTimer {
+class BenchSysTimer {
public:
void startWall();
void startCpu();
diff --git a/bench/BenchTimer.cpp b/bench/BenchTimer.cpp
new file mode 100644
index 0000000000..f3e8e3b0ec
--- /dev/null
+++ b/bench/BenchTimer.cpp
@@ -0,0 +1,94 @@
+
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "BenchTimer.h"
+#if defined(SK_BUILD_FOR_WIN32)
+ #include "BenchSysTimer_windows.h"
+#elif defined(SK_BUILD_FOR_MAC)
+ #include "BenchSysTimer_mach.h"
+#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
+ #include "BenchSysTimer_posix.h"
+#else
+ #include "BenchSysTimer_c.h"
+#endif
+
+#if SK_SUPPORT_GPU
+#include "BenchGpuTimer_gl.h"
+#endif
+
+BenchTimer::BenchTimer(SkGLContextHelper* gl)
+ : fCpu(-1.0)
+ , fWall(-1.0)
+ , fTruncatedCpu(-1.0)
+ , fTruncatedWall(-1.0)
+ , fGpu(-1.0)
+{
+ fSysTimer = new BenchSysTimer();
+ fTruncatedSysTimer = new BenchSysTimer();
+#if SK_SUPPORT_GPU
+ if (gl) {
+ fGpuTimer = new BenchGpuTimer(gl);
+ } else {
+ fGpuTimer = NULL;
+ }
+#endif
+}
+
+BenchTimer::~BenchTimer() {
+ delete fSysTimer;
+ delete fTruncatedSysTimer;
+#if SK_SUPPORT_GPU
+ delete fGpuTimer;
+#endif
+}
+
+void BenchTimer::start(double durationScale) {
+ fDurationScale = durationScale;
+
+ fSysTimer->startWall();
+ fTruncatedSysTimer->startWall();
+#if SK_SUPPORT_GPU
+ if (fGpuTimer) {
+ fGpuTimer->startGpu();
+ }
+#endif
+ fSysTimer->startCpu();
+ fTruncatedSysTimer->startCpu();
+}
+
+void BenchTimer::end() {
+ fCpu = fSysTimer->endCpu() * fDurationScale;
+#if SK_SUPPORT_GPU
+ //It is important to stop the cpu clocks first,
+ //as the following will cpu wait for the gpu to finish.
+ if (fGpuTimer) {
+ fGpu = fGpuTimer->endGpu() * fDurationScale;
+ }
+#endif
+ fWall = fSysTimer->endWall() * fDurationScale;
+}
+
+void BenchTimer::truncatedEnd() {
+ fTruncatedCpu = fTruncatedSysTimer->endCpu() * fDurationScale;
+ fTruncatedWall = fTruncatedSysTimer->endWall() * fDurationScale;
+}
+
+WallTimer::WallTimer() : fWall(-1.0), fSysTimer(new BenchSysTimer) {}
+
+WallTimer::~WallTimer() {
+ delete fSysTimer;
+}
+
+void WallTimer::start(double durationScale) {
+ fDurationScale = durationScale;
+ fSysTimer->startWall();
+}
+
+void WallTimer::end() {
+ fWall = fSysTimer->endWall() * fDurationScale;
+}
+
diff --git a/tools/timer/Timer.h b/bench/BenchTimer.h
index 7a91ac6e53..2abf10b80f 100644
--- a/tools/timer/Timer.h
+++ b/bench/BenchTimer.h
@@ -1,25 +1,18 @@
+
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#ifndef Timer_DEFINED
-#define Timer_DEFINED
+#ifndef SkBenchTimer_DEFINED
+#define SkBenchTimer_DEFINED
-#include "SkTypes.h"
+#include <SkTypes.h>
-#if defined(SK_BUILD_FOR_WIN32)
- #include "SysTimer_windows.h"
-#elif defined(SK_BUILD_FOR_MAC)
- #include "SysTimer_mach.h"
-#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
- #include "SysTimer_posix.h"
-#endif
-#if SK_SUPPORT_GPU
- #include "GpuTimer.h"
-#endif
+class BenchSysTimer;
+class BenchGpuTimer;
class SkGLContextHelper;
@@ -32,15 +25,13 @@ class SkGLContextHelper;
* times and (for GPU configurations) can be used to roughly (very
* roughly) gauge the GPU load/backlog.
*/
-class Timer {
+class BenchTimer {
public:
- explicit Timer(SkGLContextHelper* gl = NULL);
-
- void start();
- void truncatedEnd();
+ BenchTimer(SkGLContextHelper* gl = NULL);
+ ~BenchTimer();
+ void start(double durationScale = 1);
void end();
-
- // All times in milliseconds.
+ void truncatedEnd();
double fCpu;
double fWall;
double fTruncatedCpu;
@@ -48,26 +39,29 @@ public:
double fGpu;
private:
- SysTimer fSysTimer;
- SysTimer fTruncatedSysTimer;
+ BenchSysTimer* fSysTimer;
+ BenchSysTimer* fTruncatedSysTimer;
#if SK_SUPPORT_GPU
- GpuTimer fGpuTimer;
+ BenchGpuTimer* fGpuTimer;
#endif
+ double fDurationScale; // for this start/end session
};
-// Same as Timer above, supporting only fWall but with much lower overhead.
-// (Typically, ~30ns instead of Timer's ~1us.)
+// Same as BenchTimer above, supporting only fWall but with much lower overhead.
+// (Typically, ~30ns instead of BenchTimer's ~1us.)
class WallTimer {
public:
WallTimer();
+ ~WallTimer();
- void start();
+ void start(double durationScale = 1);
void end();
- double fWall; // Milliseconds.
+ double fWall;
private:
- SysTimer fSysTimer;
+ BenchSysTimer* fSysTimer;
+ double fDurationScale;
};
#endif
diff --git a/tools/timer/TimerData.cpp b/bench/TimerData.cpp
index 21529bc2e0..0cb000280b 100644
--- a/tools/timer/TimerData.cpp
+++ b/bench/TimerData.cpp
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
@@ -6,19 +7,22 @@
*/
#include "TimerData.h"
-#include "Timer.h"
+#include "BenchTimer.h"
#include <limits>
+using namespace std;
+
TimerData::TimerData(int maxNumTimings)
- : fMaxNumTimings(maxNumTimings)
- , fCurrTiming(0)
- , fWallTimes(maxNumTimings)
- , fTruncatedWallTimes(maxNumTimings)
- , fCpuTimes(maxNumTimings)
- , fTruncatedCpuTimes(maxNumTimings)
- , fGpuTimes(maxNumTimings) {}
-
-bool TimerData::appendTimes(Timer* timer) {
+: fMaxNumTimings(maxNumTimings)
+, fCurrTiming(0)
+, fWallTimes(maxNumTimings)
+, fTruncatedWallTimes(maxNumTimings)
+, fCpuTimes(maxNumTimings)
+, fTruncatedCpuTimes(maxNumTimings)
+, fGpuTimes(maxNumTimings){
+}
+
+bool TimerData::appendTimes(BenchTimer* timer) {
SkASSERT(timer != NULL);
if (fCurrTiming >= fMaxNumTimings) {
return false;
diff --git a/tools/timer/TimerData.h b/bench/TimerData.h
index 35e94dca1d..fb84df1a9e 100644
--- a/tools/timer/TimerData.h
+++ b/bench/TimerData.h
@@ -1,3 +1,4 @@
+
/*
* Copyright 2012 Google Inc.
*
@@ -22,7 +23,7 @@
#pragma warning(pop)
#endif
-class Timer;
+class BenchTimer;
class TimerData {
public:
@@ -32,12 +33,12 @@ public:
explicit TimerData(int maxNumTimings);
/**
- * Collect times from the Timer for an iteration. It will fail if called more often than
+ * Collect times from the BenchTimer for an iteration. It will fail if called more often than
* indicated in the constructor.
*
- * @param Timer Must not be null.
+ * @param BenchTimer Must not be null.
*/
- bool appendTimes(Timer*);
+ bool appendTimes(BenchTimer*);
enum Result {
kMin_Result,
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp
index 5c3b7901af..6b3f5872f2 100644
--- a/bench/benchmain.cpp
+++ b/bench/benchmain.cpp
@@ -6,6 +6,7 @@
*/
#include "BenchLogger.h"
+#include "BenchTimer.h"
#include "Benchmark.h"
#include "CrashHandler.h"
#include "GMBench.h"
@@ -23,7 +24,6 @@
#include "SkPictureRecorder.h"
#include "SkString.h"
#include "SkSurface.h"
-#include "Timer.h"
#if SK_SUPPORT_GPU
#include "GrContext.h"
@@ -530,9 +530,9 @@ int tool_main(int argc, char** argv) {
if (Benchmark::kGPU_Backend == config.backend) {
contextHelper = gContextFactory.getGLContext(config.contextType);
}
- Timer timer(contextHelper);
+ BenchTimer timer(contextHelper);
#else
- Timer timer;
+ BenchTimer timer;
#endif
double previous = std::numeric_limits<double>::infinity();
diff --git a/debugger/QT/SkDebuggerGUI.cpp b/debugger/QT/SkDebuggerGUI.cpp
index 5cecba273c..1873afca67 100644
--- a/debugger/QT/SkDebuggerGUI.cpp
+++ b/debugger/QT/SkDebuggerGUI.cpp
@@ -17,13 +17,13 @@
__SK_FORCE_IMAGE_DECODER_LINKING;
#if defined(SK_BUILD_FOR_WIN32)
- #include "SysTimer_windows.h"
+ #include "BenchSysTimer_windows.h"
#elif defined(SK_BUILD_FOR_MAC)
- #include "SysTimer_mach.h"
+ #include "BenchSysTimer_mach.h"
#elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
- #include "SysTimer_posix.h"
+ #include "BenchSysTimer_posix.h"
#else
- #include "SysTimer_c.h"
+ #include "BenchSysTimer_c.h"
#endif
@@ -202,7 +202,7 @@ public:
double totTime() const { return fTot; }
protected:
- SysTimer fTimer;
+ BenchSysTimer fTimer;
SkTDArray<bool> fSkipCommands; // has the command been deleted in the GUI?
SkTDArray<double> fTimes; // sum of time consumed for each command
SkTDArray<double> fTypeTimes; // sum of time consumed for each type of command (e.g., drawPath)
diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp
index 9ced81b98f..abfc8b77f9 100644
--- a/gyp/SampleApp.gyp
+++ b/gyp/SampleApp.gyp
@@ -150,8 +150,8 @@
'flags.gyp:flags',
'lua.gyp:lua',
'pdf.gyp:pdf',
+ 'resources.gyp:resources',
'skia_lib.gyp:skia_lib',
- 'tools.gyp:resources',
'views.gyp:views',
'views_animated.gyp:views_animated',
'xml.gyp:xml',
diff --git a/gyp/apptype_console.gypi b/gyp/apptype_console.gypi
index b9939987b8..cde87792c7 100644
--- a/gyp/apptype_console.gypi
+++ b/gyp/apptype_console.gypi
@@ -15,7 +15,7 @@
[ 'skia_os == "android" and not skia_android_framework', {
'dependencies': [
'android_deps.gyp:Android_EntryPoint',
- 'skia_launcher.gyp:skia_launcher',
+ 'android_system.gyp:skia_launcher',
],
}],
[ 'skia_os == "nacl"', {
diff --git a/gyp/bench.gyp b/gyp/bench.gyp
index 1c1943705f..15927e6413 100644
--- a/gyp/bench.gyp
+++ b/gyp/bench.gyp
@@ -9,13 +9,13 @@
'target_name': 'bench',
'type': 'executable',
'dependencies': [
+ 'bench_timer',
+ 'crash_handler.gyp:CrashHandler',
'etc1.gyp:libetc1',
'flags.gyp:flags',
'jsoncpp.gyp:jsoncpp',
+ 'resources.gyp:resources',
'skia_lib.gyp:skia_lib',
- 'tools.gyp:crash_handler',
- 'tools.gyp:resources',
- 'tools.gyp:timer',
],
'sources': [
'../bench/BenchLogger.cpp',
@@ -50,5 +50,63 @@
'gmslides.gypi',
],
},
+ {
+ 'target_name' : 'bench_timer',
+ 'type': 'static_library',
+ 'sources': [
+ '../bench/BenchTimer.h',
+ '../bench/BenchTimer.cpp',
+ '../bench/BenchSysTimer_mach.h',
+ '../bench/BenchSysTimer_mach.cpp',
+ '../bench/BenchSysTimer_posix.h',
+ '../bench/BenchSysTimer_posix.cpp',
+ '../bench/BenchSysTimer_windows.h',
+ '../bench/BenchSysTimer_windows.cpp',
+ ],
+ 'include_dirs': [
+ '../src/core',
+ '../src/gpu',
+ '../tools',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': ['../bench'],
+ },
+ 'dependencies': [
+ 'skia_lib.gyp:skia_lib',
+ ],
+ 'conditions': [
+ [ 'skia_os not in ["mac", "ios"]', {
+ 'sources!': [
+ '../bench/BenchSysTimer_mach.h',
+ '../bench/BenchSysTimer_mach.cpp',
+ ],
+ }],
+ [ 'skia_os not in ["linux", "freebsd", "openbsd", "solaris", "android", "chromeos"]', {
+ 'sources!': [
+ '../bench/BenchSysTimer_posix.h',
+ '../bench/BenchSysTimer_posix.cpp',
+ ],
+ }],
+ [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
+ 'link_settings': {
+ 'libraries': [
+ '-lrt',
+ ],
+ },
+ }],
+ [ 'skia_os != "win"', {
+ 'sources!': [
+ '../bench/BenchSysTimer_windows.h',
+ '../bench/BenchSysTimer_windows.cpp',
+ ],
+ }],
+ ['skia_gpu == 1', {
+ 'sources': [
+ '../bench/BenchGpuTimer_gl.h',
+ '../bench/BenchGpuTimer_gl.cpp',
+ ],
+ }],
+ ],
+ }
],
}
diff --git a/gyp/crash_handler.gyp b/gyp/crash_handler.gyp
new file mode 100644
index 0000000000..7e3599c8d9
--- /dev/null
+++ b/gyp/crash_handler.gyp
@@ -0,0 +1,18 @@
+{
+ 'targets': [{
+ 'target_name': 'CrashHandler',
+ 'type': 'static_library',
+ 'sources': [ '../tools/CrashHandler.cpp' ],
+ 'dependencies': [ 'skia_lib.gyp:skia_lib' ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [ '../tools' ],
+ },
+ 'all_dependent_settings': {
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'AdditionalDependencies': [ 'Dbghelp.lib' ],
+ }
+ },
+ }
+ }]
+}
diff --git a/gyp/debugger.gyp b/gyp/debugger.gyp
index 4add7439a8..84f03972df 100644
--- a/gyp/debugger.gyp
+++ b/gyp/debugger.gyp
@@ -96,8 +96,8 @@
],
'dependencies': [
'skia_lib.gyp:skia_lib',
+ 'bench.gyp:bench_timer',
'tools.gyp:picture_renderer',
- 'tools.gyp:timer',
],
'conditions': [
[ 'skia_os == "nacl"', {
diff --git a/gyp/dm.gyp b/gyp/dm.gyp
index 2d02796b45..f69ffe5f4b 100644
--- a/gyp/dm.gyp
+++ b/gyp/dm.gyp
@@ -55,12 +55,12 @@
'../src/utils/debugger/SkObjectParser.cpp',
],
'dependencies': [
+ 'crash_handler.gyp:CrashHandler',
'etc1.gyp:libetc1',
'flags.gyp:flags',
'gputest.gyp:skgputest',
'jsoncpp.gyp:jsoncpp',
'skia_lib.gyp:skia_lib',
- 'tools.gyp:crash_handler',
],
'conditions': [
['skia_android_framework', {
diff --git a/gyp/gm.gyp b/gyp/gm.gyp
index fd56e7eebe..0b0054b701 100644
--- a/gyp/gm.gyp
+++ b/gyp/gm.gyp
@@ -5,6 +5,28 @@
],
'targets': [
{
+ 'target_name': 'gm_expectations',
+ 'type': 'static_library',
+ 'include_dirs' : [
+ '../src/utils/',
+ ],
+ 'sources': [
+ '../gm/gm_expectations.h',
+ '../gm/gm_expectations.cpp',
+ '../tools/sk_tool_utils.cpp',
+ ],
+ 'dependencies': [
+ 'crash_handler.gyp:CrashHandler',
+ 'jsoncpp.gyp:jsoncpp',
+ 'skia_lib.gyp:skia_lib',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '../gm/',
+ ],
+ },
+ },
+ {
'target_name': 'gm',
'type': 'executable',
'include_dirs' : [
@@ -27,12 +49,11 @@
'dependencies': [
'etc1.gyp:libetc1',
'flags.gyp:flags',
+ 'gm.gyp:gm_expectations',
'jsoncpp.gyp:jsoncpp',
'pdf.gyp:pdf',
+ 'resources.gyp:resources',
'skia_lib.gyp:skia_lib',
- 'tools.gyp:crash_handler',
- 'tools.gyp:gm_expectations',
- 'tools.gyp:resources',
],
'conditions': [
['skia_android_framework', {
diff --git a/gyp/resources.gyp b/gyp/resources.gyp
new file mode 100644
index 0000000000..48e96c3cc5
--- /dev/null
+++ b/gyp/resources.gyp
@@ -0,0 +1,25 @@
+# Copyright 2014 Google Inc.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'resources',
+ 'type': 'static_library',
+ 'sources': [
+ '../tools/Resources.cpp',
+ '../tools/Resources.h',
+ ],
+ 'dependencies': [
+ 'flags.gyp:flags',
+ 'skia_lib.gyp:skia_lib',
+ ],
+ 'direct_dependent_settings': {
+ 'include_dirs': [
+ '../tools/',
+ ],
+ },
+ },
+ ]
+}
diff --git a/gyp/skia_launcher.gyp b/gyp/skia_launcher.gyp
deleted file mode 100644
index d9970b4290..0000000000
--- a/gyp/skia_launcher.gyp
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- 'includes': [ '../platform_tools/android/gyp/skia_launcher.gypi' ]
-}
diff --git a/gyp/tests.gyp b/gyp/tests.gyp
index 155207ed6f..80768efa35 100644
--- a/gyp/tests.gyp
+++ b/gyp/tests.gyp
@@ -11,7 +11,7 @@
'pathops_unittest.gypi',
'tests.gypi',
],
- 'dependencies': [ 'tools.gyp:crash_handler' ],
+ 'dependencies': [ 'crash_handler.gyp:CrashHandler' ],
'sources': [
'../tests/skia_test.cpp',
],
diff --git a/gyp/tests.gypi b/gyp/tests.gypi
index f135107c34..2a7dddd4ff 100644
--- a/gyp/tests.gypi
+++ b/gyp/tests.gypi
@@ -20,9 +20,9 @@
'experimental.gyp:experimental',
'flags.gyp:flags',
'pdf.gyp:pdf',
+ 'resources.gyp:resources',
'skia_lib.gyp:skia_lib',
'tools.gyp:picture_utils',
- 'tools.gyp:resources',
],
'sources': [
'../tests/Test.cpp',
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index eeb210a497..5ea127296a 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -43,86 +43,6 @@
],
],
},
- { # This would go in gm.gyp, but it's also used by skimage below.
- 'target_name': 'gm_expectations',
- 'type': 'static_library',
- 'include_dirs' : [ '../src/utils/' ],
- 'sources': [
- '../gm/gm_expectations.cpp',
- '../tools/sk_tool_utils.cpp',
- ],
- 'dependencies': [
- 'jsoncpp.gyp:jsoncpp',
- 'skia_lib.gyp:skia_lib',
- ],
- 'direct_dependent_settings': {
- 'include_dirs': [ '../gm/' ],
- },
- },
- {
- 'target_name': 'crash_handler',
- 'type': 'static_library',
- 'sources': [ '../tools/CrashHandler.cpp' ],
- 'dependencies': [ 'skia_lib.gyp:skia_lib' ],
- 'direct_dependent_settings': {
- 'include_dirs': [ '../tools' ],
- },
- 'all_dependent_settings': {
- 'msvs_settings': {
- 'VCLinkerTool': {
- 'AdditionalDependencies': [ 'Dbghelp.lib' ],
- }
- },
- }
- },
- {
- 'target_name': 'resources',
- 'type': 'static_library',
- 'sources': [ '../tools/Resources.cpp' ],
- 'dependencies': [
- 'flags.gyp:flags',
- 'skia_lib.gyp:skia_lib',
- ],
- 'direct_dependent_settings': {
- 'include_dirs': [ '../tools/', ],
- },
- },
- {
- 'target_name' : 'timer',
- 'type': 'static_library',
- 'sources': [
- '../tools/timer/Timer.cpp',
- '../tools/timer/TimerData.cpp',
- ],
- 'include_dirs': [
- '../src/core',
- '../src/gpu',
- ],
- 'direct_dependent_settings': {
- 'include_dirs': ['../tools/timer'],
- },
- 'dependencies': [
- 'skia_lib.gyp:skia_lib',
- 'jsoncpp.gyp:jsoncpp',
- ],
- 'conditions': [
- ['skia_gpu == 1', {
- 'sources': [ '../tools/timer/GpuTimer.cpp' ],
- }],
- [ 'skia_os in ["mac", "ios"]', {
- 'sources': [ '../tools/timer/SysTimer_mach.cpp' ],
- }],
- [ 'skia_os == "win"', {
- 'sources': [ '../tools/timer/SysTimer_windows.cpp' ],
- }],
- [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "android", "chromeos"]', {
- 'sources': [ '../tools/timer/SysTimer_posix.cpp' ],
- }],
- [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
- 'link_settings': { 'libraries': [ '-lrt' ] },
- }],
- ],
- },
{
'target_name': 'skdiff',
'type': 'executable',
@@ -258,8 +178,8 @@
'../src/utils/',
],
'dependencies': [
- 'gm_expectations',
'flags.gyp:flags',
+ 'gm.gyp:gm_expectations',
'jsoncpp.gyp:jsoncpp',
'skia_lib.gyp:skia_lib',
],
@@ -379,13 +299,14 @@
'../src/lazy/',
],
'dependencies': [
- 'timer',
- 'crash_handler',
+ 'bench.gyp:bench_timer',
+ 'crash_handler.gyp:CrashHandler',
'flags.gyp:flags',
'jsoncpp.gyp:jsoncpp',
'skia_lib.gyp:skia_lib',
'tools.gyp:picture_renderer',
'tools.gyp:picture_utils',
+ 'tools.gyp:timer_data',
],
},
{
@@ -401,7 +322,7 @@
'../src/lazy',
],
'dependencies': [
- 'timer',
+ 'bench.gyp:bench_timer',
'flags.gyp:flags',
'skia_lib.gyp:skia_lib',
],
@@ -417,7 +338,7 @@
'../src/images',
],
'dependencies': [
- 'timer',
+ 'bench.gyp:bench_timer',
'flags.gyp:flags',
'skia_lib.gyp:skia_lib',
],
@@ -436,7 +357,7 @@
'../src/lazy',
],
'dependencies': [
- 'timer',
+ 'bench.gyp:bench_timer',
'flags.gyp:flags',
'skia_lib.gyp:skia_lib',
],
@@ -584,8 +505,9 @@
# Bench code:
],
'dependencies': [
- 'timer',
+ 'bench.gyp:bench_timer',
'flags.gyp:flags',
+ 'tools.gyp:timer_data',
'skia_lib.gyp:skia_lib',
'tools.gyp:picture_renderer',
'tools.gyp:picture_utils',
@@ -622,6 +544,17 @@
'skia_lib.gyp:skia_lib',
],
},
+ {
+ 'target_name': 'timer_data',
+ 'type': 'static_library',
+ 'sources': [
+ '../bench/TimerData.cpp',
+ ],
+ 'dependencies': [
+ 'skia_lib.gyp:skia_lib',
+ 'jsoncpp.gyp:jsoncpp'
+ ]
+ }
],
'conditions': [
['skia_shared_lib',
diff --git a/platform_tools/android/gyp/skia_android.gypi b/platform_tools/android/gyp/skia_android.gypi
index 624b599bd6..9ebee7cc6d 100644
--- a/platform_tools/android/gyp/skia_android.gypi
+++ b/platform_tools/android/gyp/skia_android.gypi
@@ -45,6 +45,13 @@
],
},
{
+ 'target_name': 'skia_launcher',
+ 'type': 'executable',
+ 'sources': [
+ '../launcher/skia_launcher.cpp',
+ ],
+ },
+ {
'target_name': 'SampleApp_APK',
'type': 'none',
'dependencies': [
diff --git a/platform_tools/android/gyp/skia_launcher.gypi b/platform_tools/android/gyp/skia_launcher.gypi
deleted file mode 100644
index f8b5dfd794..0000000000
--- a/platform_tools/android/gyp/skia_launcher.gypi
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- 'targets': [{
- 'target_name': 'skia_launcher',
- 'type': 'executable',
- 'sources': [ '../launcher/skia_launcher.cpp' ],
- }]
-}
diff --git a/tools/DumpRecord.cpp b/tools/DumpRecord.cpp
index 6e679a5430..2376fb9cf0 100644
--- a/tools/DumpRecord.cpp
+++ b/tools/DumpRecord.cpp
@@ -10,8 +10,8 @@
#include "SkRecord.h"
#include "SkRecordDraw.h"
+#include "BenchTimer.h"
#include "DumpRecord.h"
-#include "Timer.h"
namespace {
@@ -33,7 +33,7 @@ public:
template <typename T>
void operator()(const T& command) {
- Timer timer;
+ BenchTimer timer;
timer.start();
fDraw(command);
timer.end();
diff --git a/tools/PictureBenchmark.cpp b/tools/PictureBenchmark.cpp
index 85a49f4e5e..30967c7381 100644
--- a/tools/PictureBenchmark.cpp
+++ b/tools/PictureBenchmark.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "Timer.h"
+#include "BenchTimer.h"
#include "PictureBenchmark.h"
#include "SkCanvas.h"
#include "SkPicture.h"
@@ -42,13 +42,13 @@ void PictureBenchmark::setTimersToShow(bool wall,
fTimerTypes |= gpu ? TimerData::kGpu_Flag : 0;
}
-Timer* PictureBenchmark::setupTimer(bool useGLTimer) {
+BenchTimer* PictureBenchmark::setupTimer(bool useGLTimer) {
#if SK_SUPPORT_GPU
if (useGLTimer && fRenderer != NULL && fRenderer->isUsingGpuDevice()) {
- return SkNEW_ARGS(Timer, (fRenderer->getGLContext()));
+ return SkNEW_ARGS(BenchTimer, (fRenderer->getGLContext()));
}
#endif
- return SkNEW_ARGS(Timer, (NULL));
+ return SkNEW_ARGS(BenchTimer, (NULL));
}
PictureRenderer* PictureBenchmark::setRenderer(sk_tools::PictureRenderer* renderer) {
@@ -147,11 +147,11 @@ void PictureBenchmark::run(SkPicture* pict) {
// seems to cause problems (i.e., INVALID_OPERATIONs) on several
// platforms. To work around this, we disable the gpu timer on the
// long running timer.
- SkAutoTDelete<Timer> longRunningTimer(this->setupTimer());
+ SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer());
TimerData longRunningTimerData(numOuterLoops);
for (int outer = 0; outer < numOuterLoops; ++outer) {
- SkAutoTDelete<Timer> perTileTimer(this->setupTimer(false));
+ SkAutoTDelete<BenchTimer> perTileTimer(this->setupTimer(false));
TimerData perTileTimerData(numInnerLoops);
longRunningTimer->start();
@@ -201,11 +201,11 @@ void PictureBenchmark::run(SkPicture* pict) {
numInnerLoops);
}
} else {
- SkAutoTDelete<Timer> longRunningTimer(this->setupTimer());
+ SkAutoTDelete<BenchTimer> longRunningTimer(this->setupTimer());
TimerData longRunningTimerData(numOuterLoops);
for (int outer = 0; outer < numOuterLoops; ++outer) {
- SkAutoTDelete<Timer> perRunTimer(this->setupTimer(false));
+ SkAutoTDelete<BenchTimer> perRunTimer(this->setupTimer(false));
TimerData perRunTimerData(numInnerLoops);
longRunningTimer->start();
diff --git a/tools/PictureBenchmark.h b/tools/PictureBenchmark.h
index 1ddd18ea16..142d52685e 100644
--- a/tools/PictureBenchmark.h
+++ b/tools/PictureBenchmark.h
@@ -13,8 +13,8 @@
#include "SkTypes.h"
#include "TimerData.h"
+class BenchTimer;
class SkPicture;
-class Timer;
namespace sk_tools {
@@ -67,7 +67,7 @@ private:
PictureResultsWriter* fWriter;
- Timer* setupTimer(bool useGLTimer = true);
+ BenchTimer* setupTimer(bool useGLTimer = true);
};
}
diff --git a/tools/bbh_shootout.cpp b/tools/bbh_shootout.cpp
index 64fc6d87d8..e657917aad 100644
--- a/tools/bbh_shootout.cpp
+++ b/tools/bbh_shootout.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "Timer.h"
+#include "BenchTimer.h"
#include "Benchmark.h"
#include "LazyDecodeBitmap.h"
#include "PictureBenchmark.h"
@@ -64,7 +64,7 @@ static void do_benchmark_work(sk_tools::PictureRenderer* renderer,
BBoxType bBoxType,
SkPicture* pic,
const int numRepeats,
- Timer* timer) {
+ BenchTimer* timer) {
renderer->setBBoxHierarchyType(bBoxType);
renderer->setGridSize(FLAGS_tilesize, FLAGS_tilesize);
renderer->init(pic, NULL, NULL, NULL, false);
@@ -106,14 +106,14 @@ int tool_main(int argc, char** argv) {
if (!includeBBoxType[bBoxType]) { continue; }
if (FLAGS_playback > 0) {
sk_tools::TiledPictureRenderer playbackRenderer;
- Timer playbackTimer;
+ BenchTimer playbackTimer;
do_benchmark_work(&playbackRenderer, (BBoxType)bBoxType,
picture, FLAGS_playback, &playbackTimer);
measurement.fPlaybackAverage[bBoxType] = playbackTimer.fCpu;
}
if (FLAGS_record > 0) {
sk_tools::RecordPictureRenderer recordRenderer;
- Timer recordTimer;
+ BenchTimer recordTimer;
do_benchmark_work(&recordRenderer, (BBoxType)bBoxType,
picture, FLAGS_record, &recordTimer);
measurement.fRecordAverage[bBoxType] = recordTimer.fCpu;
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index 503269af6a..d9b767b2aa 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -6,7 +6,7 @@
*/
#include "BenchLogger.h"
-#include "Timer.h"
+#include "BenchTimer.h"
#include "CopyTilesRenderer.h"
#include "CrashHandler.h"
#include "LazyDecodeBitmap.h"
diff --git a/tools/bench_playback.cpp b/tools/bench_playback.cpp
index 6ebe19d36f..26fa1c7ee8 100644
--- a/tools/bench_playback.cpp
+++ b/tools/bench_playback.cpp
@@ -16,8 +16,10 @@
#include "../include/record/SkRecording.h"
+#include "BenchTimer.h"
#include "Stats.h"
-#include "Timer.h"
+
+typedef WallTimer Timer;
__SK_FORCE_IMAGE_DECODER_LINKING;
@@ -76,16 +78,15 @@ static void bench(SkPMColor* scratch, SkPicture& src, const char* name) {
// Draw once to warm any caches. The first sample otherwise can be very noisy.
draw(*record, *picture, canvas.get());
- WallTimer timer;
- const double scale = timescale();
+ Timer timer;
SkAutoTMalloc<double> samples(FLAGS_samples);
for (int i = 0; i < FLAGS_samples; i++) {
// We assume timer overhead (typically, ~30ns) is insignificant
// compared to draw runtime (at least ~100us, usually several ms).
- timer.start();
+ timer.start(timescale());
draw(*record, *picture, canvas.get());
timer.end();
- samples[i] = timer.fWall * scale;
+ samples[i] = timer.fWall;
}
Stats stats(samples.get(), FLAGS_samples);
diff --git a/tools/bench_record.cpp b/tools/bench_record.cpp
index 545731900b..0024c2ccdb 100644
--- a/tools/bench_record.cpp
+++ b/tools/bench_record.cpp
@@ -14,9 +14,11 @@
#include "SkStream.h"
#include "SkString.h"
+#include "BenchTimer.h"
#include "LazyDecodeBitmap.h"
#include "Stats.h"
-#include "Timer.h"
+
+typedef WallTimer Timer;
__SK_FORCE_IMAGE_DECODER_LINKING;
@@ -79,13 +81,12 @@ static void bench_record(const SkPicture& src,
rerecord(src, bbhFactory);
// Rerecord once to see how many times we should loop to make timer overhead insignificant.
- WallTimer timer;
- const double scale = timescale();
+ Timer timer;
do {
- timer.start();
+ timer.start(timescale());
rerecord(src, bbhFactory);
timer.end();
- } while (timer.fWall * scale < timerOverhead); // Loop just in case something bizarre happens.
+ } while (timer.fWall < timerOverhead); // Loop just in case something bizarre happens.
// We want (timer overhead / measurement) to be less than FLAGS_overheadGoal.
// So in each sample, we'll loop enough times to have made that true for our first measurement.
@@ -93,12 +94,12 @@ static void bench_record(const SkPicture& src,
SkAutoTMalloc<double> samples(FLAGS_samples);
for (int i = 0; i < FLAGS_samples; i++) {
- timer.start();
+ timer.start(timescale());
for (int j = 0; j < loops; j++) {
rerecord(src, bbhFactory);
}
timer.end();
- samples[i] = timer.fWall * scale / loops;
+ samples[i] = timer.fWall / loops;
}
Stats stats(samples.get(), FLAGS_samples);
@@ -131,13 +132,12 @@ int tool_main(int argc, char** argv) {
// Each run will use this timer overhead estimate to guess how many times it should run.
static const int kOverheadLoops = 10000000;
- WallTimer timer;
+ Timer timer;
double overheadEstimate = 0.0;
- const double scale = timescale();
for (int i = 0; i < kOverheadLoops; i++) {
- timer.start();
+ timer.start(timescale());
timer.end();
- overheadEstimate += timer.fWall * scale;
+ overheadEstimate += timer.fWall;
}
overheadEstimate /= kOverheadLoops;
diff --git a/tools/skpdiff/skpdiff_util.cpp b/tools/skpdiff/skpdiff_util.cpp
index 983bee20b3..171721c3be 100644
--- a/tools/skpdiff/skpdiff_util.cpp
+++ b/tools/skpdiff/skpdiff_util.cpp
@@ -83,7 +83,7 @@ const char* cl_error_to_string(cl_int err) {
}
#endif
-// TODO refactor Timer to be used here
+// TODO refactor BenchTimer to be used here
double get_seconds() {
#if SK_BUILD_FOR_WIN32
LARGE_INTEGER currentTime;
diff --git a/tools/timer/Timer.cpp b/tools/timer/Timer.cpp
deleted file mode 100644
index 4f3fc85cff..0000000000
--- a/tools/timer/Timer.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "Timer.h"
-
-Timer::Timer(SkGLContextHelper* gl)
- : fCpu(-1.0)
- , fWall(-1.0)
- , fTruncatedCpu(-1.0)
- , fTruncatedWall(-1.0)
- , fGpu(-1.0)
-#if SK_SUPPORT_GPU
- , fGpuTimer(gl)
-#endif
- {}
-
-void Timer::start() {
- fSysTimer.startWall();
- fTruncatedSysTimer.startWall();
-#if SK_SUPPORT_GPU
- fGpuTimer.start();
-#endif
- fSysTimer.startCpu();
- fTruncatedSysTimer.startCpu();
-}
-
-void Timer::end() {
- fCpu = fSysTimer.endCpu();
-#if SK_SUPPORT_GPU
- //It is important to stop the cpu clocks first,
- //as the following will cpu wait for the gpu to finish.
- fGpu = fGpuTimer.end();
-#endif
- fWall = fSysTimer.endWall();
-}
-
-void Timer::truncatedEnd() {
- fTruncatedCpu = fTruncatedSysTimer.endCpu();
- fTruncatedWall = fTruncatedSysTimer.endWall();
-}
-
-WallTimer::WallTimer() : fWall(-1.0) {}
-
-void WallTimer::start() {
- fSysTimer.startWall();
-}
-
-void WallTimer::end() {
- fWall = fSysTimer.endWall();
-}