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

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

Issue 1204153002: Add samplingTime mode to nanobench (Closed) Base URL: https://skia.googlesource.com/skia.git@upload_loopSKP
Patch Set: rebase Created 5 years, 5 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 /* 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 #include "SysTimer_posix.h" 7 #include "SysTimer_posix.h"
8 8
9 static double interval_in_ms(timespec start_clock, timespec end_clock) 9 static double interval_in_ms(timespec start_clock, timespec end_clock)
10 { 10 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 } 42 }
43 43
44 double SysTimer::endWall() { 44 double SysTimer::endWall() {
45 timespec end_wall; 45 timespec end_wall;
46 if (-1 == clock_gettime(CLOCK_MONOTONIC, &end_wall)) { 46 if (-1 == clock_gettime(CLOCK_MONOTONIC, &end_wall)) {
47 timespec none = {0, 0}; 47 timespec none = {0, 0};
48 end_wall = none; 48 end_wall = none;
49 } 49 }
50 return interval_in_ms(fWall, end_wall); 50 return interval_in_ms(fWall, end_wall);
51 } 51 }
52
53 static timespec init_launch_time() {
54 timespec launchTime;
55 if (-1 == clock_gettime(CLOCK_MONOTONIC, &launchTime)) {
56 timespec none = {0, 0};
57 return none;
58 }
59 return launchTime;
60 };
61
62 double GetTimeMs() {
63 static const timespec launchTime = init_launch_time();
64 timespec now;
65 if (-1 == clock_gettime(CLOCK_MONOTONIC, &now)) {
66 return 0;
67 }
68 return interval_in_ms(launchTime, now);
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698