summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkwesolowski <krzysztof.wesolowski@rainlabs.pl>2014-07-26 10:38:26 (GMT)
committerkwesolowski <krzysztof.wesolowski@rainlabs.pl>2014-07-26 10:38:26 (GMT)
commit97d709208389dbf17b08311caa197e49e51275d9 (patch)
tree0773841142ce391a9629c921eec0d3f82faa4318 /src
parent43879bb63cab1dd6236f04d1ece5724de283193b (diff)
downloadNinja-97d709208389dbf17b08311caa197e49e51275d9.zip
Ninja-97d709208389dbf17b08311caa197e49e51275d9.tar.gz
Ninja-97d709208389dbf17b08311caa197e49e51275d9.tar.bz2
Changed implementation to provide load from 0 to ProcessorCount
This makes this implementation more consisten with POSIX load avarage.
Diffstat (limited to 'src')
-rw-r--r--src/util.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/util.cc b/src/util.cc
index 66ddcb1..8b69b71 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -461,19 +461,21 @@ double GetLoadAverage() {
FILETIME idle_time, kernel_time, user_time;
BOOL get_system_time_succeeded = GetSystemTimes(&idle_time, &kernel_time, &user_time);
- double result;
+ double posix_compatible_load;
if (get_system_time_succeeded) {
uint64_t idle_ticks = FileTimeToTickCount(idle_time);
//kernel_time from GetSystemTimes already includes idle_time
uint64_t total_ticks = FileTimeToTickCount(kernel_time) + FileTimeToTickCount(user_time);
- result = CalculateProcessorLoad(idle_ticks, total_ticks);
+ double processor_load = CalculateProcessorLoad(idle_ticks, total_ticks);
+ posix_compatible_load = processor_load * GetProcessorCount();
+
} else {
- result = -0.0;
+ posix_compatible_load = -0.0;
}
- return result;
+ return posix_compatible_load;
}
#else
double GetLoadAverage() {