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

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

Issue 346753003: Revert of Move BenchTimer to tools as Timer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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
« no previous file with comments | « tools/timer/SysTimer_windows.h ('k') | tools/timer/Timer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #include "SysTimer_windows.h"
8
9 static ULONGLONG win_cpu_time() {
10 FILETIME createTime;
11 FILETIME exitTime;
12 FILETIME usrTime;
13 FILETIME sysTime;
14 if (0 == GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &sysTi me, &usrTime)) {
15 return 0;
16 }
17 ULARGE_INTEGER start_cpu_sys;
18 ULARGE_INTEGER start_cpu_usr;
19 start_cpu_sys.LowPart = sysTime.dwLowDateTime;
20 start_cpu_sys.HighPart = sysTime.dwHighDateTime;
21 start_cpu_usr.LowPart = usrTime.dwLowDateTime;
22 start_cpu_usr.HighPart = usrTime.dwHighDateTime;
23 return start_cpu_sys.QuadPart + start_cpu_usr.QuadPart;
24 }
25
26 void SysTimer::startWall() {
27 if (0 == ::QueryPerformanceCounter(&fStartWall)) {
28 fStartWall.QuadPart = 0;
29 }
30 }
31 void SysTimer::startCpu() {
32 fStartCpu = win_cpu_time();
33 }
34
35 double SysTimer::endCpu() {
36 ULONGLONG end_cpu = win_cpu_time();
37 return static_cast<double>(end_cpu - fStartCpu) / 10000.0L;
38 }
39 double SysTimer::endWall() {
40 LARGE_INTEGER end_wall;
41 if (0 == ::QueryPerformanceCounter(&end_wall)) {
42 end_wall.QuadPart = 0;
43 }
44
45 LARGE_INTEGER ticks_elapsed;
46 ticks_elapsed.QuadPart = end_wall.QuadPart - fStartWall.QuadPart;
47
48 LARGE_INTEGER frequency;
49 if (0 == ::QueryPerformanceFrequency(&frequency)) {
50 return 0.0L;
51 } else {
52 return static_cast<double>(ticks_elapsed.QuadPart)
53 / static_cast<double>(frequency.QuadPart)
54 * 1000.0L;
55 }
56 }
OLDNEW
« no previous file with comments | « tools/timer/SysTimer_windows.h ('k') | tools/timer/Timer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698