[SIGAR-19] Change cpu time units to milliseconds
This commit is contained in:
parent
70cefa7c18
commit
4b98533cba
|
@ -104,13 +104,11 @@ typedef enum {
|
||||||
perf_offsets[ix] ? \
|
perf_offsets[ix] ? \
|
||||||
*((DWORD *)((BYTE *)counter_block + perf_offsets[ix])) : 0
|
*((DWORD *)((BYTE *)counter_block + perf_offsets[ix])) : 0
|
||||||
|
|
||||||
/* 1/100ns units to seconds */
|
/* 1/100ns units to milliseconds */
|
||||||
#define NS100_2SEC(t) ((t) / 10000000)
|
|
||||||
|
|
||||||
#define NS100_2MSEC(t) ((t) / 10000)
|
#define NS100_2MSEC(t) ((t) / 10000)
|
||||||
|
|
||||||
#define PERF_VAL_CPU(ix) \
|
#define PERF_VAL_CPU(ix) \
|
||||||
NS100_2SEC(PERF_VAL(ix))
|
NS100_2MSEC(PERF_VAL(ix))
|
||||||
|
|
||||||
#define MS_LOOPBACK_ADAPTER "Microsoft Loopback Adapter"
|
#define MS_LOOPBACK_ADAPTER "Microsoft Loopback Adapter"
|
||||||
#define NETIF_LA "la"
|
#define NETIF_LA "la"
|
||||||
|
@ -606,11 +604,11 @@ static int get_idle_cpu(sigar_t *sigar, sigar_cpu_t *cpu,
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
int i;
|
int i;
|
||||||
for (i=0; i<num; i++) {
|
for (i=0; i<num; i++) {
|
||||||
cpu->idle += NS100_2SEC(info[i].IdleTime.QuadPart);
|
cpu->idle += NS100_2MSEC(info[i].IdleTime.QuadPart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (idx < num) {
|
else if (idx < num) {
|
||||||
cpu->idle = NS100_2SEC(info[idx].IdleTime.QuadPart);
|
cpu->idle = NS100_2MSEC(info[idx].IdleTime.QuadPart);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ERROR_INVALID_DATA;
|
return ERROR_INVALID_DATA;
|
||||||
|
@ -676,9 +674,9 @@ static int sigar_cpu_ntsys_get(sigar_t *sigar, sigar_cpu_t *cpu)
|
||||||
SIGAR_ZERO(cpu);
|
SIGAR_ZERO(cpu);
|
||||||
|
|
||||||
for (i=0; i<num; i++) {
|
for (i=0; i<num; i++) {
|
||||||
cpu->idle += NS100_2SEC(info[i].IdleTime.QuadPart);
|
cpu->idle += NS100_2MSEC(info[i].IdleTime.QuadPart);
|
||||||
cpu->user += NS100_2SEC(info[i].UserTime.QuadPart);
|
cpu->user += NS100_2MSEC(info[i].UserTime.QuadPart);
|
||||||
cpu->sys += NS100_2SEC(info[i].KernelTime.QuadPart -
|
cpu->sys += NS100_2MSEC(info[i].KernelTime.QuadPart -
|
||||||
info[i].IdleTime.QuadPart);
|
info[i].IdleTime.QuadPart);
|
||||||
cpu->total += cpu->idle + cpu->user + cpu->sys;
|
cpu->total += cpu->idle + cpu->user + cpu->sys;
|
||||||
}
|
}
|
||||||
|
@ -805,9 +803,9 @@ static int sigar_cpu_list_ntsys_get(sigar_t *sigar,
|
||||||
SIGAR_ZERO(cpu);
|
SIGAR_ZERO(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
idle = NS100_2SEC(info[i].IdleTime.QuadPart);
|
idle = NS100_2MSEC(info[i].IdleTime.QuadPart);
|
||||||
user = NS100_2SEC(info[i].UserTime.QuadPart);
|
user = NS100_2MSEC(info[i].UserTime.QuadPart);
|
||||||
sys = NS100_2SEC(info[i].KernelTime.QuadPart -
|
sys = NS100_2MSEC(info[i].KernelTime.QuadPart -
|
||||||
info[i].IdleTime.QuadPart);
|
info[i].IdleTime.QuadPart);
|
||||||
cpu->idle += idle;
|
cpu->idle += idle;
|
||||||
cpu->user += user;
|
cpu->user += user;
|
||||||
|
|
Loading…
Reference in New Issue