now has hrtime Measurement

This commit is contained in:
2017-04-23 18:46:13 +02:00
parent 836f8d18b0
commit fad367ca0b
6 changed files with 121 additions and 1546 deletions

View File

@ -1,6 +1,7 @@
import 'typings-global'
import * as beautycolor from 'beautycolor'
import * as smartq from 'smartq'
import * as process from 'process'
let doText: boolean = false
let moduleName: string = 'undefined module name'
@ -29,3 +30,25 @@ export let stop = (): Promise<number> => {
done.resolve(earlyExecutionTime)
return done.promise
}
export class hrtMeasurement {
private _started: boolean = false
private _hrTimeStart
start () {
this._started = true
this._hrTimeStart = process.hrtime()
}
stop () {
if (this._started === false) {
console.log('Hasn\'t started yet')
return
}
let diffTime = process.hrtime(this._hrTimeStart)
let nanoSeconds = (diffTime[0] * 1e9) + diffTime[1]
let milliSeconds = nanoSeconds / 1000000
return {
nanoSeconds: nanoSeconds,
milliSeconds: milliSeconds
}
}
}