// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
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;
}
}microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/utils/node/stopWatch.ts
22lines · modepreview