Permalink
Browse files

Merge pull request #26 from tmm1/patch-1

Improve code clarity of counter processing loop
  • Loading branch information...
2 parents 5060bf4 + 193a73f commit 3cbd351123a75a51aae8aed9740b602dd4628f5e @kastner kastner committed Feb 11, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 stats.js
View
@@ -172,12 +172,13 @@ config.configFile(process.argv[2], function (config, oldConfig) {
var key;
for (key in counters) {
- var value = counters[key] / (flushInterval / 1000);
- var message = 'stats.' + key + ' ' + value + ' ' + ts + "\n";
- message += 'stats_counts.' + key + ' ' + counters[key] + ' ' + ts + "\n";
- statString += message;
- counters[key] = 0;
+ var value = counters[key];
+ var valuePerSecond = value / (flushInterval / 1000); // calculate "per second" rate
+
+ statString += 'stats.' + key + ' ' + valuePerSecond + ' ' + ts + "\n";
+ statString += 'stats_counts.' + key + ' ' + value + ' ' + ts + "\n";
+ counters[key] = 0;
numStats += 1;
}

0 comments on commit 3cbd351

Please sign in to comment.