microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/utils/node/stopWatch.ts
19lines · modecode
| 1 | export class StopWatch { |
| 2 | private startTime = process.hrtime(); |
| 3 | private nanoSecondsInOneMilliSecond = 1000000; |
| 4 | private milliSecondsInOneSecond = 1000; |
| 5 | |
| 6 | public stopAsMilliseconds(): number { |
| 7 | let ellapsedTime = process.hrtime(this.startTime); |
| 8 | let smallPartInNanoSeconds = ellapsedTime[1]; |
| 9 | let smallPartInMilliSeconds = smallPartInNanoSeconds / this.nanoSecondsInOneMilliSecond; |
| 10 | let bigPartInSeconds = ellapsedTime[0]; |
| 11 | let bigPartInMilliSeconds = bigPartInSeconds * this.milliSecondsInOneSecond; |
| 12 | let ellapsedTimeInMilliSeconds = bigPartInMilliSeconds + smallPartInMilliSeconds; |
| 13 | return ellapsedTimeInMilliSeconds; |
| 14 | } |
| 15 | |
| 16 | public stopAsSeconds(): number { |
| 17 | return this.stopAsMilliseconds() / this.milliSecondsInOneSecond; |
| 18 | } |
| 19 | } |