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

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

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_posix.h ('k') | tools/timer/SysTimer_windows.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_posix.h"
8
9 static double interval_in_ms(timespec start_clock, timespec end_clock)
10 {
11 double duration_clock;
12 if ((end_clock.tv_nsec - start_clock.tv_nsec) < 0) {
13 duration_clock = (end_clock.tv_sec - start_clock.tv_sec - 1) * 1000;
14 duration_clock += (1000000000 + end_clock.tv_nsec - start_clock.tv_nsec) / 1000000.0;
15 } else {
16 duration_clock = (end_clock.tv_sec - start_clock.tv_sec) * 1000;
17 duration_clock += (end_clock.tv_nsec - start_clock.tv_nsec) / 1000000.0;
18 }
19 return duration_clock;
20 }
21
22 void SysTimer::startWall() {
23 if (-1 == clock_gettime(CLOCK_MONOTONIC, &fWall)) {
24 timespec none = {0, 0};
25 fWall = none;
26 }
27 }
28 void SysTimer::startCpu() {
29 if (-1 == clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &fCpu)) {
30 timespec none = {0, 0};
31 fCpu = none;
32 }
33 }
34
35 double SysTimer::endCpu() {
36 timespec end_cpu;
37 if (-1 == clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end_cpu)) {
38 timespec none = {0, 0};
39 end_cpu = none;
40 }
41 return interval_in_ms(fCpu, end_cpu);
42 }
43
44 double SysTimer::endWall() {
45 timespec end_wall;
46 if (-1 == clock_gettime(CLOCK_MONOTONIC, &end_wall)) {
47 timespec none = {0, 0};
48 end_wall = none;
49 }
50 return interval_in_ms(fWall, end_wall);
51 }
OLDNEW
« no previous file with comments | « tools/timer/SysTimer_posix.h ('k') | tools/timer/SysTimer_windows.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698