use a single, shared timestamps array between all pings

This commit is contained in:
Nick Krecklow
2020-05-08 01:22:07 -05:00
parent 3ddb2c9a08
commit c2494af82d
7 changed files with 55 additions and 30 deletions

23
lib/time.js Normal file
View File

@ -0,0 +1,23 @@
class TimeTracker {
constructor () {
this._points = []
}
newTimestamp () {
const timestamp = new Date().getTime()
this._points.push(timestamp)
if (this._points.length > 72) {
this._points.shift()
}
return timestamp
}
getPoints () {
return this._points
}
}
module.exports = TimeTracker