diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-11-12 20:47:35 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-11-12 20:47:35 (GMT) |
commit | 12be2ffc1998c59df346186eaf4d7364e94ffdf1 (patch) | |
tree | 42d183608e3b38bfde442f074ff24234400b2f40 /src | |
parent | 23c11b4efae2e1a8aeeb98aaaed96ad6ec76b460 (diff) | |
parent | a023d9923cbb584680fb53760747a75e380b520a (diff) | |
download | Ninja-12be2ffc1998c59df346186eaf4d7364e94ffdf1.zip Ninja-12be2ffc1998c59df346186eaf4d7364e94ffdf1.tar.gz Ninja-12be2ffc1998c59df346186eaf4d7364e94ffdf1.tar.bz2 |
Merge pull request #850 from sgraham/ocd
whitespace/comment/wrap fixes, no intended functionality change
Diffstat (limited to 'src')
-rw-r--r-- | src/graph.cc | 2 | ||||
-rw-r--r-- | src/util.cc | 35 | ||||
-rw-r--r-- | 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<Node*>::iterator i = edge->outputs_.begin(); i != edge->outputs_.end(); ++i) { diff --git a/src/util.cc b/src/util.cc index 7717ef4..746d7ed 100644 --- a/src/util.cc +++ b/src/util.cc @@ -510,33 +510,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; } @@ -549,22 +550,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 13730af..8ca7f56 100644 --- a/src/util_test.cc +++ b/src/util_test.cc @@ -343,10 +343,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); |