Comparing version 3.2.0 to 3.3.0
@@ -27,31 +27,26 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unitimer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var count = 0 | ||
var startTime = null | ||
var tookTime = -1 | ||
var startTimes = {} | ||
return { | ||
start: function (id) { | ||
start: function (id = 'default') { | ||
var time = now() | ||
if (id) { | ||
startTimes[id] = time | ||
} else { | ||
startTime = time | ||
} | ||
startTimes[id] = time | ||
return this | ||
}, | ||
stop: function (id) { | ||
const t = id ? startTimes[id] : startTime | ||
if (!t) { return -1 } | ||
var took = now() - t | ||
minTime = minTime === -1 ? took : Math.min(minTime, took) | ||
maxTime = maxTime === -1 ? took : Math.max(maxTime, took) | ||
totalTime += took | ||
stop: function (id = 'default') { | ||
const startTime = startTimes[id] | ||
if (!startTime) { return -1 } | ||
tookTime = now() - startTime | ||
minTime = minTime === -1 ? tookTime : Math.min(minTime, tookTime) | ||
maxTime = maxTime === -1 ? tookTime : Math.max(maxTime, tookTime) | ||
totalTime += tookTime | ||
count += 1 | ||
meanTime = totalTime / count | ||
if (id) { | ||
startTimes[id] = undefined | ||
} else { | ||
startTime = null | ||
} | ||
return took | ||
startTimes[id] = undefined | ||
return tookTime | ||
}, | ||
took: function () { | ||
return tookTime | ||
}, | ||
total: function () { | ||
@@ -74,2 +69,3 @@ return totalTime | ||
return { | ||
took: tookTime, | ||
total: totalTime, | ||
@@ -84,3 +80,4 @@ mean: meanTime, | ||
return (tag ? '[' + tag + '] ' : '') + | ||
'mean: ' + toFixed(meanTime, dp) + | ||
'took: ' + toFixed(tookTime, dp) + | ||
'ms, mean: ' + toFixed(meanTime, dp) + | ||
'ms, total: ' + toFixed(totalTime, dp) + | ||
@@ -87,0 +84,0 @@ 'ms, count: ' + count + |
@@ -16,31 +16,26 @@ var now = require('./now') | ||
var count = 0 | ||
var startTime = null | ||
var tookTime = -1 | ||
var startTimes = {} | ||
return { | ||
start: function (id) { | ||
start: function (id = 'default') { | ||
var time = now() | ||
if (id) { | ||
startTimes[id] = time | ||
} else { | ||
startTime = time | ||
} | ||
startTimes[id] = time | ||
return this | ||
}, | ||
stop: function (id) { | ||
const t = id ? startTimes[id] : startTime | ||
if (!t) { return -1 } | ||
var took = now() - t | ||
minTime = minTime === -1 ? took : Math.min(minTime, took) | ||
maxTime = maxTime === -1 ? took : Math.max(maxTime, took) | ||
totalTime += took | ||
stop: function (id = 'default') { | ||
const startTime = startTimes[id] | ||
if (!startTime) { return -1 } | ||
tookTime = now() - startTime | ||
minTime = minTime === -1 ? tookTime : Math.min(minTime, tookTime) | ||
maxTime = maxTime === -1 ? tookTime : Math.max(maxTime, tookTime) | ||
totalTime += tookTime | ||
count += 1 | ||
meanTime = totalTime / count | ||
if (id) { | ||
startTimes[id] = undefined | ||
} else { | ||
startTime = null | ||
} | ||
return took | ||
startTimes[id] = undefined | ||
return tookTime | ||
}, | ||
took: function () { | ||
return tookTime | ||
}, | ||
total: function () { | ||
@@ -63,2 +58,3 @@ return totalTime | ||
return { | ||
took: tookTime, | ||
total: totalTime, | ||
@@ -73,3 +69,4 @@ mean: meanTime, | ||
return (tag ? '[' + tag + '] ' : '') + | ||
'mean: ' + toFixed(meanTime, dp) + | ||
'took: ' + toFixed(tookTime, dp) + | ||
'ms, mean: ' + toFixed(meanTime, dp) + | ||
'ms, total: ' + toFixed(totalTime, dp) + | ||
@@ -76,0 +73,0 @@ 'ms, count: ' + count + |
{ | ||
"name": "unitimer", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "Universal timer (Node.js and browser)", | ||
@@ -49,9 +49,9 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"ava": "0.19.1", | ||
"browserify": "14.3.0", | ||
"ava": "^0.19.1", | ||
"browserify": "^14.3.0", | ||
"proxyquire": "^1.7.10", | ||
"sinon": "2.2.0", | ||
"standard": "10.0.2", | ||
"sinon": "^2.3.1", | ||
"standard": "^10.0.2", | ||
"watchify": "^3.7.0" | ||
} | ||
} |
@@ -187,2 +187,3 @@ const test = require('ava') | ||
{ | ||
took: 10000, | ||
total: 15000, | ||
@@ -212,7 +213,7 @@ mean: 7500, | ||
timer.info(), | ||
'mean: 7500.029949ms, total: 15000.059898ms, count: 2, min: 5000.009901ms, max: 10000.049996999998ms' | ||
'took: 10000.049996999998ms, mean: 7500.029949ms, total: 15000.059898ms, count: 2, min: 5000.009901ms, max: 10000.049996999998ms' | ||
) | ||
t.is( | ||
timer.info(3), | ||
'mean: 7500.030ms, total: 15000.060ms, count: 2, min: 5000.010ms, max: 10000.050ms' | ||
'took: 10000.050ms, mean: 7500.030ms, total: 15000.060ms, count: 2, min: 5000.010ms, max: 10000.050ms' | ||
) | ||
@@ -236,3 +237,3 @@ t.is(typeof timer.log, 'function') | ||
foo.info(), | ||
'[foo] mean: 5000ms, total: 5000ms, count: 1, min: 5000ms, max: 5000ms' | ||
'[foo] took: 5000ms, mean: 5000ms, total: 5000ms, count: 1, min: 5000ms, max: 5000ms' | ||
) | ||
@@ -257,9 +258,9 @@ hrtime.restore() | ||
foo.info(), | ||
'[foo] mean: 5000ms, total: 5000ms, count: 1, min: 5000ms, max: 5000ms' | ||
'[foo] took: 5000ms, mean: 5000ms, total: 5000ms, count: 1, min: 5000ms, max: 5000ms' | ||
) | ||
t.is( | ||
bar.info(), | ||
'[bar] mean: 10000ms, total: 10000ms, count: 1, min: 10000ms, max: 10000ms' | ||
'[bar] took: 10000ms, mean: 10000ms, total: 10000ms, count: 1, min: 10000ms, max: 10000ms' | ||
) | ||
hrtime.restore() | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164017
475