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

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

Issue 1420923003: Revert of SkTime::GetNSecs() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « tools/timer/SysTimer_windows.cpp ('k') | tools/timer/Timer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * 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
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 #ifndef Timer_DEFINED 7 #ifndef Timer_DEFINED
8 #define Timer_DEFINED 8 #define Timer_DEFINED
9 9
10 #include "SkTypes.h"
10 #include "SkString.h" 11 #include "SkString.h"
11 #include "SkTime.h"
12 #include "SkTypes.h"
13 12
13 #if defined(SK_BUILD_FOR_WIN32)
14 #include "SysTimer_windows.h"
15 #elif defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS)
16 #include "SysTimer_mach.h"
17 #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_ANDROID)
18 #include "SysTimer_posix.h"
19 #endif
20
21 #if SK_SUPPORT_GPU
22 #include "GpuTimer.h"
23 #endif
24
25 class SkGLContext;
26
27 /**
28 * SysTimers and GpuTimers are implemented orthogonally.
29 * This class combines 2 SysTimers and a GpuTimer into one single,
30 * platform specific Timer with a simple interface. The truncated
31 * timer doesn't include the time required for the GPU to finish
32 * its rendering. It should always be <= the un-truncated system
33 * times and (for GPU configurations) can be used to roughly (very
34 * roughly) gauge the GPU load/backlog.
35 */
36 class Timer {
37 public:
38 explicit Timer(SkGLContext* gl = nullptr);
39
40 void start();
41 void truncatedEnd();
42 void end();
43
44 // All times in milliseconds.
45 double fCpu;
46 double fWall;
47 double fTruncatedCpu;
48 double fTruncatedWall;
49 double fGpu;
50
51 private:
52 SysTimer fSysTimer;
53 SysTimer fTruncatedSysTimer;
54 #if SK_SUPPORT_GPU
55 GpuTimer fGpuTimer;
56 #endif
57 };
58
59 // Same as Timer above, supporting only fWall but with much lower overhead.
60 // (Typically, ~30ns instead of Timer's ~1us.)
14 class WallTimer { 61 class WallTimer {
15 public: 62 public:
16 WallTimer() : fWall(-1) {} 63 WallTimer();
17 64
18 void start() { fWall = SkTime::GetNSecs(); } 65 void start();
19 void end() { fWall = (SkTime::GetNSecs() - fWall) * 1e-6; } 66 void end();
20 67
21 double fWall; // Milliseconds. 68 double fWall; // Milliseconds.
69
70 private:
71 SysTimer fSysTimer;
22 }; 72 };
23 73
24 SkString HumanizeMs(double); 74 SkString HumanizeMs(double);
25 75
26 #endif 76 #endif
OLDNEW
« no previous file with comments | « tools/timer/SysTimer_windows.cpp ('k') | tools/timer/Timer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698