Comparing version 3.0.2 to 3.1.0-alpha.1
@@ -17,5 +17,6 @@ "use strict"; | ||
var Stat = function () { | ||
function Stat(name) { | ||
function Stat(name, samples) { | ||
(0, _classCallCheck2["default"])(this, Stat); | ||
this.name = name; | ||
this.sampleSize = 1; | ||
this.reset(); | ||
@@ -25,5 +26,12 @@ } | ||
(0, _createClass2["default"])(Stat, [{ | ||
key: "setSampleSize", | ||
value: function setSampleSize(samples) { | ||
this.sampleSize = samples; | ||
return this; | ||
} | ||
}, { | ||
key: "incrementCount", | ||
value: function incrementCount() { | ||
this.addCount(1); | ||
return this; | ||
} | ||
@@ -34,2 +42,3 @@ }, { | ||
this.subtractCount(1); | ||
return this; | ||
} | ||
@@ -39,3 +48,8 @@ }, { | ||
value: function addCount(value) { | ||
this.count += value; | ||
this._count += value; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -45,3 +59,8 @@ }, { | ||
value: function subtractCount(value) { | ||
this.count -= value; | ||
this._count -= value; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -51,5 +70,9 @@ }, { | ||
value: function addTime(time) { | ||
this.time += time; | ||
this.lastTiming = time; | ||
this.count++; | ||
this._time += time; | ||
this._lastTiming = time; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -61,2 +84,3 @@ }, { | ||
this._timerPending = true; | ||
return this; | ||
} | ||
@@ -67,3 +91,3 @@ }, { | ||
if (!this._timerPending) { | ||
return; | ||
return this; | ||
} | ||
@@ -73,7 +97,31 @@ | ||
this._timerPending = false; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
}, { | ||
key: "getSampleAverageCount", | ||
value: function getSampleAverageCount() { | ||
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0; | ||
} | ||
}, { | ||
key: "getSampleAverageTime", | ||
value: function getSampleAverageTime() { | ||
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0; | ||
} | ||
}, { | ||
key: "getSampleHz", | ||
value: function getSampleHz() { | ||
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1000) : 0; | ||
} | ||
}, { | ||
key: "getAverageCount", | ||
value: function getAverageCount() { | ||
return this.samples > 0 ? this.count / this.samples : 0; | ||
} | ||
}, { | ||
key: "getAverageTime", | ||
value: function getAverageTime() { | ||
return this.count > 0 ? this.time / this.count : 0; | ||
return this.samples > 0 ? this.time / this.samples : 0; | ||
} | ||
@@ -83,3 +131,3 @@ }, { | ||
value: function getHz() { | ||
return this.time > 0 ? this.count / (this.time / 1000) : 0; | ||
return this.time > 0 ? this.samples / (this.time / 1000) : 0; | ||
} | ||
@@ -91,6 +139,27 @@ }, { | ||
this.count = 0; | ||
this.samples = 0; | ||
this.lastTiming = 0; | ||
this.lastSampleTime = 0; | ||
this.lastSampleCount = 0; | ||
this._count = 0; | ||
this._time = 0; | ||
this._samples = 0; | ||
this._startTime = 0; | ||
this._timerPending = false; | ||
return this; | ||
} | ||
}, { | ||
key: "_checkSampling", | ||
value: function _checkSampling() { | ||
if (this._samples === this.sampleSize) { | ||
this.lastSampleTime = this._time; | ||
this.lastSampleCount = this._count; | ||
this.count += this._count; | ||
this.time += this._time; | ||
this.samples += this._samples; | ||
this._time = 0; | ||
this._count = 0; | ||
this._samples = 0; | ||
} | ||
} | ||
}]); | ||
@@ -97,0 +166,0 @@ return Stat; |
import getHiResTimestamp from '../utils/hi-res-timestamp'; | ||
export default class Stat { | ||
constructor(name) { | ||
constructor(name, samples) { | ||
this.name = name; | ||
this.sampleSize = 1; | ||
this.reset(); | ||
} | ||
setSampleSize(samples) { | ||
this.sampleSize = samples; | ||
return this; | ||
} | ||
incrementCount() { | ||
this.addCount(1); | ||
return this; | ||
} | ||
@@ -14,16 +21,31 @@ | ||
this.subtractCount(1); | ||
return this; | ||
} | ||
addCount(value) { | ||
this.count += value; | ||
this._count += value; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
subtractCount(value) { | ||
this.count -= value; | ||
this._count -= value; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
addTime(time) { | ||
this.time += time; | ||
this.lastTiming = time; | ||
this.count++; | ||
this._time += time; | ||
this._lastTiming = time; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -34,2 +56,3 @@ | ||
this._timerPending = true; | ||
return this; | ||
} | ||
@@ -39,3 +62,3 @@ | ||
if (!this._timerPending) { | ||
return; | ||
return this; | ||
} | ||
@@ -45,10 +68,30 @@ | ||
this._timerPending = false; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
getSampleAverageCount() { | ||
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0; | ||
} | ||
getSampleAverageTime() { | ||
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0; | ||
} | ||
getSampleHz() { | ||
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1000) : 0; | ||
} | ||
getAverageCount() { | ||
return this.samples > 0 ? this.count / this.samples : 0; | ||
} | ||
getAverageTime() { | ||
return this.count > 0 ? this.time / this.count : 0; | ||
return this.samples > 0 ? this.time / this.samples : 0; | ||
} | ||
getHz() { | ||
return this.time > 0 ? this.count / (this.time / 1000) : 0; | ||
return this.time > 0 ? this.samples / (this.time / 1000) : 0; | ||
} | ||
@@ -59,8 +102,28 @@ | ||
this.count = 0; | ||
this.samples = 0; | ||
this.lastTiming = 0; | ||
this.lastSampleTime = 0; | ||
this.lastSampleCount = 0; | ||
this._count = 0; | ||
this._time = 0; | ||
this._samples = 0; | ||
this._startTime = 0; | ||
this._timerPending = false; | ||
return this; | ||
} | ||
_checkSampling() { | ||
if (this._samples === this.sampleSize) { | ||
this.lastSampleTime = this._time; | ||
this.lastSampleCount = this._count; | ||
this.count += this._count; | ||
this.time += this._time; | ||
this.samples += this._samples; | ||
this._time = 0; | ||
this._count = 0; | ||
this._samples = 0; | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=stat.js.map |
@@ -6,6 +6,7 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck"; | ||
var Stat = function () { | ||
function Stat(name) { | ||
function Stat(name, samples) { | ||
_classCallCheck(this, Stat); | ||
this.name = name; | ||
this.sampleSize = 1; | ||
this.reset(); | ||
@@ -15,5 +16,12 @@ } | ||
_createClass(Stat, [{ | ||
key: "setSampleSize", | ||
value: function setSampleSize(samples) { | ||
this.sampleSize = samples; | ||
return this; | ||
} | ||
}, { | ||
key: "incrementCount", | ||
value: function incrementCount() { | ||
this.addCount(1); | ||
return this; | ||
} | ||
@@ -24,2 +32,3 @@ }, { | ||
this.subtractCount(1); | ||
return this; | ||
} | ||
@@ -29,3 +38,8 @@ }, { | ||
value: function addCount(value) { | ||
this.count += value; | ||
this._count += value; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -35,3 +49,8 @@ }, { | ||
value: function subtractCount(value) { | ||
this.count -= value; | ||
this._count -= value; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -41,5 +60,9 @@ }, { | ||
value: function addTime(time) { | ||
this.time += time; | ||
this.lastTiming = time; | ||
this.count++; | ||
this._time += time; | ||
this._lastTiming = time; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -51,2 +74,3 @@ }, { | ||
this._timerPending = true; | ||
return this; | ||
} | ||
@@ -57,3 +81,3 @@ }, { | ||
if (!this._timerPending) { | ||
return; | ||
return this; | ||
} | ||
@@ -63,7 +87,31 @@ | ||
this._timerPending = false; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
}, { | ||
key: "getSampleAverageCount", | ||
value: function getSampleAverageCount() { | ||
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0; | ||
} | ||
}, { | ||
key: "getSampleAverageTime", | ||
value: function getSampleAverageTime() { | ||
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0; | ||
} | ||
}, { | ||
key: "getSampleHz", | ||
value: function getSampleHz() { | ||
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1000) : 0; | ||
} | ||
}, { | ||
key: "getAverageCount", | ||
value: function getAverageCount() { | ||
return this.samples > 0 ? this.count / this.samples : 0; | ||
} | ||
}, { | ||
key: "getAverageTime", | ||
value: function getAverageTime() { | ||
return this.count > 0 ? this.time / this.count : 0; | ||
return this.samples > 0 ? this.time / this.samples : 0; | ||
} | ||
@@ -73,3 +121,3 @@ }, { | ||
value: function getHz() { | ||
return this.time > 0 ? this.count / (this.time / 1000) : 0; | ||
return this.time > 0 ? this.samples / (this.time / 1000) : 0; | ||
} | ||
@@ -81,6 +129,27 @@ }, { | ||
this.count = 0; | ||
this.samples = 0; | ||
this.lastTiming = 0; | ||
this.lastSampleTime = 0; | ||
this.lastSampleCount = 0; | ||
this._count = 0; | ||
this._time = 0; | ||
this._samples = 0; | ||
this._startTime = 0; | ||
this._timerPending = false; | ||
return this; | ||
} | ||
}, { | ||
key: "_checkSampling", | ||
value: function _checkSampling() { | ||
if (this._samples === this.sampleSize) { | ||
this.lastSampleTime = this._time; | ||
this.lastSampleCount = this._count; | ||
this.count += this._count; | ||
this.time += this._time; | ||
this.samples += this._samples; | ||
this._time = 0; | ||
this._count = 0; | ||
this._samples = 0; | ||
} | ||
} | ||
}]); | ||
@@ -87,0 +156,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "3.0.2", | ||
"version": "3.1.0-alpha.1", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "javascript", |
import getHiResTimestamp from '../utils/hi-res-timestamp'; | ||
export default class Stat { | ||
constructor(name) { | ||
constructor(name, samples) { | ||
this.name = name; | ||
this.sampleSize = 1; | ||
this.reset(); | ||
} | ||
setSampleSize(samples) { | ||
this.sampleSize = samples; | ||
return this; | ||
} | ||
// Call to increment count (+1) | ||
incrementCount() { | ||
this.addCount(1); | ||
return this; | ||
} | ||
@@ -17,2 +26,4 @@ | ||
this.subtractCount(1); | ||
return this; | ||
} | ||
@@ -22,3 +33,7 @@ | ||
addCount(value) { | ||
this.count += value; | ||
this._count += value; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -28,3 +43,7 @@ | ||
subtractCount(value) { | ||
this.count -= value; | ||
this._count -= value; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -34,5 +53,8 @@ | ||
addTime(time) { | ||
this.time += time; | ||
this.lastTiming = time; | ||
this.count++; | ||
this._time += time; | ||
this._lastTiming = time; | ||
this._samples++; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
@@ -44,2 +66,4 @@ | ||
this._timerPending = true; | ||
return this; | ||
} | ||
@@ -50,3 +74,3 @@ | ||
if (!this._timerPending) { | ||
return; | ||
return this; | ||
} | ||
@@ -56,7 +80,28 @@ | ||
this._timerPending = false; | ||
this._checkSampling(); | ||
return this; | ||
} | ||
getSampleAverageCount() { | ||
return this.sampleSize > 0 ? this.lastSampleCount / this.sampleSize : 0; | ||
} | ||
// Calculate average time / count for the previous window | ||
getSampleAverageTime() { | ||
return this.sampleSize > 0 ? this.lastSampleTime / this.sampleSize : 0; | ||
} | ||
// Calculate counts per second for the previous window | ||
getSampleHz() { | ||
return this.lastSampleTime > 0 ? this.sampleSize / (this.lastSampleTime / 1000) : 0; | ||
} | ||
getAverageCount() { | ||
return this.samples > 0 ? this.count / this.samples : 0; | ||
} | ||
// Calculate average time / count | ||
getAverageTime() { | ||
return this.count > 0 ? this.time / this.count : 0; | ||
return this.samples > 0 ? this.time / this.samples : 0; | ||
} | ||
@@ -66,3 +111,3 @@ | ||
getHz() { | ||
return this.time > 0 ? this.count / (this.time / 1000) : 0; | ||
return this.time > 0 ? this.samples / (this.time / 1000) : 0; | ||
} | ||
@@ -73,6 +118,27 @@ | ||
this.count = 0; | ||
this.samples = 0; | ||
this.lastTiming = 0; | ||
this.lastSampleTime = 0; | ||
this.lastSampleCount = 0; | ||
this._count = 0; | ||
this._time = 0; | ||
this._samples = 0; | ||
this._startTime = 0; | ||
this._timerPending = false; | ||
return this; | ||
} | ||
_checkSampling() { | ||
if (this._samples === this.sampleSize) { | ||
this.lastSampleTime = this._time; | ||
this.lastSampleCount = this._count; | ||
this.count += this._count; | ||
this.time += this._time; | ||
this.samples += this._samples; | ||
this._time = 0; | ||
this._count = 0; | ||
this._samples = 0; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
326693
4244
0
121
2