Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Side by Side Diff: tools/timer/Timer.cpp

Issue 344213003: Move BenchTimer to tools as Timer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: thiago Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1
2 /* 1 /*
3 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
4 * 3 *
5 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 5 * found in the LICENSE file.
7 */ 6 */
8 #include "BenchTimer.h" 7 #include "Timer.h"
9 #if defined(SK_BUILD_FOR_WIN32)
10 #include "BenchSysTimer_windows.h"
11 #elif defined(SK_BUILD_FOR_MAC)
12 #include "BenchSysTimer_mach.h"
13 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
14 #include "BenchSysTimer_posix.h"
15 #else
16 #include "BenchSysTimer_c.h"
17 #endif
18 8
19 #if SK_SUPPORT_GPU 9 Timer::Timer(SkGLContextHelper* gl)
20 #include "BenchGpuTimer_gl.h"
21 #endif
22
23 BenchTimer::BenchTimer(SkGLContextHelper* gl)
24 : fCpu(-1.0) 10 : fCpu(-1.0)
25 , fWall(-1.0) 11 , fWall(-1.0)
26 , fTruncatedCpu(-1.0) 12 , fTruncatedCpu(-1.0)
27 , fTruncatedWall(-1.0) 13 , fTruncatedWall(-1.0)
28 , fGpu(-1.0) 14 , fGpu(-1.0)
29 {
30 fSysTimer = new BenchSysTimer();
31 fTruncatedSysTimer = new BenchSysTimer();
32 #if SK_SUPPORT_GPU 15 #if SK_SUPPORT_GPU
33 if (gl) { 16 , fGpuTimer(gl)
34 fGpuTimer = new BenchGpuTimer(gl);
35 } else {
36 fGpuTimer = NULL;
37 }
38 #endif 17 #endif
18 {}
19
20 void Timer::start() {
21 fSysTimer.startWall();
22 fTruncatedSysTimer.startWall();
23 #if SK_SUPPORT_GPU
24 fGpuTimer.start();
25 #endif
26 fSysTimer.startCpu();
27 fTruncatedSysTimer.startCpu();
39 } 28 }
40 29
41 BenchTimer::~BenchTimer() { 30 void Timer::end() {
42 delete fSysTimer; 31 fCpu = fSysTimer.endCpu();
43 delete fTruncatedSysTimer;
44 #if SK_SUPPORT_GPU
45 delete fGpuTimer;
46 #endif
47 }
48
49 void BenchTimer::start(double durationScale) {
50 fDurationScale = durationScale;
51
52 fSysTimer->startWall();
53 fTruncatedSysTimer->startWall();
54 #if SK_SUPPORT_GPU
55 if (fGpuTimer) {
56 fGpuTimer->startGpu();
57 }
58 #endif
59 fSysTimer->startCpu();
60 fTruncatedSysTimer->startCpu();
61 }
62
63 void BenchTimer::end() {
64 fCpu = fSysTimer->endCpu() * fDurationScale;
65 #if SK_SUPPORT_GPU 32 #if SK_SUPPORT_GPU
66 //It is important to stop the cpu clocks first, 33 //It is important to stop the cpu clocks first,
67 //as the following will cpu wait for the gpu to finish. 34 //as the following will cpu wait for the gpu to finish.
68 if (fGpuTimer) { 35 fGpu = fGpuTimer.end();
69 fGpu = fGpuTimer->endGpu() * fDurationScale;
70 }
71 #endif 36 #endif
72 fWall = fSysTimer->endWall() * fDurationScale; 37 fWall = fSysTimer.endWall();
73 } 38 }
74 39
75 void BenchTimer::truncatedEnd() { 40 void Timer::truncatedEnd() {
76 fTruncatedCpu = fTruncatedSysTimer->endCpu() * fDurationScale; 41 fTruncatedCpu = fTruncatedSysTimer.endCpu();
77 fTruncatedWall = fTruncatedSysTimer->endWall() * fDurationScale; 42 fTruncatedWall = fTruncatedSysTimer.endWall();
78 } 43 }
79 44
80 WallTimer::WallTimer() : fWall(-1.0), fSysTimer(new BenchSysTimer) {} 45 WallTimer::WallTimer() : fWall(-1.0) {}
81 46
82 WallTimer::~WallTimer() { 47 void WallTimer::start() {
83 delete fSysTimer; 48 fSysTimer.startWall();
84 }
85
86 void WallTimer::start(double durationScale) {
87 fDurationScale = durationScale;
88 fSysTimer->startWall();
89 } 49 }
90 50
91 void WallTimer::end() { 51 void WallTimer::end() {
92 fWall = fSysTimer->endWall() * fDurationScale; 52 fWall = fSysTimer.endWall();
93 } 53 }
94
OLDNEW
« gyp/tools.gyp ('K') | « tools/timer/Timer.h ('k') | tools/timer/TimerData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698