Skip to content

Commit

Permalink
Use array to store counters and stopwatches.
Browse files Browse the repository at this point in the history
  • Loading branch information
janus926 committed Sep 8, 2013
1 parent edcd298 commit 7ce6b6e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var hrtime = require('./lib/hrtime');

var counter = {};
var stopwatch = {};
var counter = [];
var stopwatch = [];
var timestamp = {};

var utils = {
Expand All @@ -11,7 +11,7 @@ var utils = {
this.value = 0;
this.elapsed = [0, 0];
this.startTime = null;
counter[name] = this;
counter.push(this);
},

Stopwatch: function (name) {
Expand All @@ -22,7 +22,7 @@ var utils = {
this.splits = 0;
this.lastSplit = [0, 0];
this.lapsElapsed = [0, 0];
stopwatch[name] = this;
stopwatch.push(this);
},

timestamp: function (thing, where) {
Expand All @@ -33,12 +33,12 @@ var utils = {

summary: function () {
console.log('Counter:');
for (var name in counter)
console.log(' ' + counter[name]);
for (var i = 0; i < counter.length; ++i)
console.log(' ' + counter[i]);

console.log('Stopwatch:');
for (var name in stopwatch)
console.log(' ' + stopwatch[name]);
for (var i = 0; i < stopwatch.length; ++i)
console.log(' ' + stopwatch[i]);

var compare = function (a, b) {
var a0 = a[1][0];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bench-utils",
"version": "0.0.9",
"version": "0.1.0",
"description": "Utilities for benchmarking, such as counter, stopwatch, and timestamp.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 7ce6b6e

Please sign in to comment.