From a023d9923cbb584680fb53760747a75e380b520a Mon Sep 17 00:00:00 2001 From: Scott Graham Date: Wed, 12 Nov 2014 12:39:20 -0800 Subject: whitespace/comment/wrap fixes, no intended functionality change --- src/graph.cc | 2 +- src/util.cc | 35 +++++++++++++++++++---------------- src/util_test.cc | 4 ++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/graph.cc b/src/graph.cc index 223661c..2829669 100644 --- a/src/graph.cc +++ b/src/graph.cc @@ -131,7 +131,7 @@ bool DependencyScan::RecomputeDirty(Edge* edge, string* err) { } bool DependencyScan::RecomputeOutputsDirty(Edge* edge, - Node* most_recent_input) { + Node* most_recent_input) { string command = edge->EvaluateCommand(true); for (vector::iterator i = edge->outputs_.begin(); i != edge->outputs_.end(); ++i) { diff --git a/src/util.cc b/src/util.cc index 4df81dd..e0320eb 100644 --- a/src/util.cc +++ b/src/util.cc @@ -508,33 +508,34 @@ static double CalculateProcessorLoad(uint64_t idle_ticks, uint64_t total_ticks) static uint64_t previous_idle_ticks = 0; static uint64_t previous_total_ticks = 0; static double previous_load = -0.0; - + uint64_t idle_ticks_since_last_time = idle_ticks - previous_idle_ticks; uint64_t total_ticks_since_last_time = total_ticks - previous_total_ticks; - + bool first_call = (previous_total_ticks == 0); bool ticks_not_updated_since_last_call = (total_ticks_since_last_time == 0); - + double load; if (first_call || ticks_not_updated_since_last_call) { load = previous_load; } else { - //calculate load - double idle_to_total_ratio = ((double)idle_ticks_since_last_time) / total_ticks_since_last_time; + // Calculate load. + double idle_to_total_ratio = + ((double)idle_ticks_since_last_time) / total_ticks_since_last_time; double load_since_last_call = 1.0 - idle_to_total_ratio; - - //filter/smooth result when possible + + // Filter/smooth result when possible. if(previous_load > 0) { load = 0.9 * previous_load + 0.1 * load_since_last_call; } else { load = load_since_last_call; } } - + previous_load = load; previous_total_ticks = total_ticks; previous_idle_ticks = idle_ticks; - + return load; } @@ -547,22 +548,24 @@ static uint64_t FileTimeToTickCount(const FILETIME & ft) double GetLoadAverage() { FILETIME idle_time, kernel_time, user_time; - BOOL get_system_time_succeeded = GetSystemTimes(&idle_time, &kernel_time, &user_time); - + BOOL get_system_time_succeeded = + GetSystemTimes(&idle_time, &kernel_time, &user_time); + 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); - + + // kernel_time from GetSystemTimes already includes idle_time. + uint64_t total_ticks = + FileTimeToTickCount(kernel_time) + FileTimeToTickCount(user_time); + double processor_load = CalculateProcessorLoad(idle_ticks, total_ticks); posix_compatible_load = processor_load * GetProcessorCount(); } else { posix_compatible_load = -0.0; } - + return posix_compatible_load; } #else diff --git a/src/util_test.cc b/src/util_test.cc index 5bbf397..1ee8f35 100644 --- a/src/util_test.cc +++ b/src/util_test.cc @@ -339,10 +339,10 @@ TEST(CanonicalizePath, NotNullTerminated) { TEST(PathEscaping, TortureTest) { string result; - + GetWin32EscapedString("foo bar\\\"'$@d!st!c'\\path'\\", &result); EXPECT_EQ("\"foo bar\\\\\\\"'$@d!st!c'\\path'\\\\\"", result); - result.clear(); + result.clear(); GetShellEscapedString("foo bar\"/'$@d!st!c'/path'", &result); EXPECT_EQ("'foo bar\"/'\\''$@d!st!c'\\''/path'\\'''", result); -- cgit v0.12