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

Unified Diff: tools/timer/SysTimer_posix.cpp

Issue 344213003: Move BenchTimer to tools as Timer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixes 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 side-by-side diff with in-line comments
Download patch
Index: tools/timer/SysTimer_posix.cpp
diff --git a/bench/BenchSysTimer_posix.cpp b/tools/timer/SysTimer_posix.cpp
similarity index 54%
rename from bench/BenchSysTimer_posix.cpp
rename to tools/timer/SysTimer_posix.cpp
index e6767e5af2267c0c83df90ee39c0f3496fac09ff..4b7d708aab0c4a7e899da8c55ddb409f43845a16 100644
--- a/bench/BenchSysTimer_posix.cpp
+++ b/tools/timer/SysTimer_posix.cpp
@@ -1,57 +1,51 @@
-
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "BenchSysTimer_posix.h"
-
-//Time
-#include <time.h>
+#include "SysTimer_posix.h"
-static double intervalInMSec(const timespec start_clock
- , const timespec end_clock)
+static double interval_in_ms(timespec start_clock, timespec end_clock)
{
double duration_clock;
if ((end_clock.tv_nsec - start_clock.tv_nsec) < 0) {
- duration_clock = (end_clock.tv_sec - start_clock.tv_sec-1)*1000;
- duration_clock += (1000000000 + end_clock.tv_nsec - start_clock.tv_nsec)
- / 1000000.0;
+ duration_clock = (end_clock.tv_sec - start_clock.tv_sec - 1) * 1000;
+ duration_clock += (1000000000 + end_clock.tv_nsec - start_clock.tv_nsec) / 1000000.0;
} else {
- duration_clock = (end_clock.tv_sec - start_clock.tv_sec)*1000;
+ duration_clock = (end_clock.tv_sec - start_clock.tv_sec) * 1000;
duration_clock += (end_clock.tv_nsec - start_clock.tv_nsec) / 1000000.0;
}
return duration_clock;
}
-void BenchSysTimer::startWall() {
- if (-1 == clock_gettime(CLOCK_MONOTONIC, &this->fWall)) {
+void SysTimer::startWall() {
+ if (-1 == clock_gettime(CLOCK_MONOTONIC, &fWall)) {
timespec none = {0, 0};
- this->fWall = none;
+ fWall = none;
}
}
-void BenchSysTimer::startCpu() {
- if (-1 == clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &this->fCpu)) {
+void SysTimer::startCpu() {
+ if (-1 == clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &fCpu)) {
timespec none = {0, 0};
- this->fCpu = none;
+ fCpu = none;
}
}
-double BenchSysTimer::endCpu() {
+double SysTimer::endCpu() {
timespec end_cpu;
if (-1 == clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end_cpu)) {
timespec none = {0, 0};
end_cpu = none;
}
- return intervalInMSec(this->fCpu, end_cpu);
+ return interval_in_ms(fCpu, end_cpu);
}
-double BenchSysTimer::endWall() {
+double SysTimer::endWall() {
timespec end_wall;
if (-1 == clock_gettime(CLOCK_MONOTONIC, &end_wall)) {
timespec none = {0, 0};
end_wall = none;
}
- return intervalInMSec(this->fWall, end_wall);
+ return interval_in_ms(fWall, end_wall);
}

Powered by Google App Engine
This is Rietveld 408576698