summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 528d1fd)
raw | patch | inline | side by side (parent: 528d1fd)
author | Vincent Brillault <git@lerya.net> | |
Wed, 4 Feb 2015 20:09:12 +0000 (21:09 +0100) | ||
committer | Vincent Brillault <git@lerya.net> | |
Sat, 28 Feb 2015 06:35:42 +0000 (07:35 +0100) |
src/turbostat.c | patch | blob | history |
diff --git a/src/turbostat.c b/src/turbostat.c
index 5236eeecaf759dd998e312bc04f70502f10d3362..aa23e141f93c52ecb873e8c0b782504def2980b8 100644 (file)
--- a/src/turbostat.c
+++ b/src/turbostat.c
#include <sys/resource.h>
#include <fcntl.h>
#include <signal.h>
-#include <sys/time.h>
#include <stdlib.h>
#include <dirent.h>
#include <string.h>
#include "collectd.h"
#include "common.h"
#include "plugin.h"
+#include "utils_time.h"
#define PLUGIN_NAME "turbostat"
struct cpu_topology *cpus;
} topology;
-struct timeval tv_even, tv_odd, tv_delta;
+cdtime_t time_even, time_odd, time_delta;
/*****************************
* MSR Manipulation helpers *
char name[DATA_MAX_NAME_LEN];
double interval_float;
- interval_float = tv_delta.tv_sec + tv_delta.tv_usec/1000000.0;
+ interval_float = CDTIME_T_TO_DOUBLE(time_delta);
ssnprintf(name, sizeof(name), "cpu%02d", t->cpu_id);
if (!initialized) {
if ((ret = for_all_cpus(get_counters, EVEN_COUNTERS)) < 0)
goto out;
- gettimeofday(&tv_even, (struct timezone *)NULL);
+ time_even = cdtime();
is_even = 1;
initialized = 1;
ret = 0;
if (is_even) {
if ((ret = for_all_cpus(get_counters, ODD_COUNTERS)) < 0)
goto out;
- gettimeofday(&tv_odd, (struct timezone *)NULL);
+ time_odd = cdtime();
is_even = 0;
- timersub(&tv_odd, &tv_even, &tv_delta);
+ time_delta = time_odd - time_even;
if ((ret = for_all_cpus_delta(ODD_COUNTERS, EVEN_COUNTERS)) < 0)
goto out;
if ((ret = for_all_cpus(submit_counters, DELTA_COUNTERS)) < 0)
} else {
if ((ret = for_all_cpus(get_counters, EVEN_COUNTERS)) < 0)
goto out;
- gettimeofday(&tv_even, (struct timezone *)NULL);
+ time_even = cdtime();
is_even = 1;
- timersub(&tv_even, &tv_odd, &tv_delta);
+ time_delta = time_even - time_odd;
if ((ret = for_all_cpus_delta(EVEN_COUNTERS, ODD_COUNTERS)) < 0)
goto out;
if ((ret = for_all_cpus(submit_counters, DELTA_COUNTERS)) < 0)