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 · modepreview

export class StopWatch {
    private startTime = process.hrtime();
    private nanoSecondsInOneMilliSecond = 1000000;
    private milliSecondsInOneSecond = 1000;

    public stopAsMilliseconds(): number {
        let ellapsedTime = process.hrtime(this.startTime);
        let smallPartInNanoSeconds = ellapsedTime[1];
        let smallPartInMilliSeconds = smallPartInNanoSeconds / this.nanoSecondsInOneMilliSecond;
        let bigPartInSeconds = ellapsedTime[0];
        let bigPartInMilliSeconds = bigPartInSeconds * this.milliSecondsInOneSecond;
        let ellapsedTimeInMilliSeconds = bigPartInMilliSeconds + smallPartInMilliSeconds;
        return ellapsedTimeInMilliSeconds;
    }

    public stopAsSeconds(): number {
        return this.stopAsMilliseconds() / this.milliSecondsInOneSecond;
    }
}