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

Unified Diff: base/process/process_metrics_openbsd.cc

Issue 139103007: Use TimeTicks instead of gettimeofday in ProcessMetrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reverty Created 6 years, 8 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
« no previous file with comments | « base/process/process_metrics_mac.cc ('k') | base/process/process_metrics_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/process_metrics_openbsd.cc
diff --git a/base/process/process_metrics_openbsd.cc b/base/process/process_metrics_openbsd.cc
index a37436289fdaf955b559849b6b3253cb29548374..72927a1b5786b5d3246328fe4c09e31eeaae8ba0 100644
--- a/base/process/process_metrics_openbsd.cc
+++ b/base/process/process_metrics_openbsd.cc
@@ -106,22 +106,16 @@ static int GetProcessCPU(pid_t pid) {
}
double ProcessMetrics::GetCPUUsage() {
- struct timeval now;
+ TimeTicks time = TimeTicks::Now();
- int retval = gettimeofday(&now, NULL);
- if (retval)
- return 0;
-
- int64 time = TimeValToMicroseconds(now);
-
- if (last_cpu_time_ == 0) {
+ if (last_cpu_ == 0) {
// First call, just set the last values.
last_cpu_time_ = time;
last_cpu_ = GetProcessCPU(process_);
return 0;
}
- int64 time_delta = time - last_cpu_time_;
+ int64 time_delta = (time - last_cpu_time_).InMicroseconds();
DCHECK_NE(time_delta, 0);
if (time_delta == 0)
@@ -139,7 +133,6 @@ double ProcessMetrics::GetCPUUsage() {
ProcessMetrics::ProcessMetrics(ProcessHandle process)
: process_(process),
- last_cpu_time_(0),
last_system_time_(0),
last_cpu_(0) {
« no previous file with comments | « base/process/process_metrics_mac.cc ('k') | base/process/process_metrics_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698