microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
bedf110fbb4cf82fb995f4cf2770e8339d5adbea

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/utils/node/stopWatch.ts

19lines · modecode

1export 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}