microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
a31b007c2af965bbb579b8e9ae0054a403891c95

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/utils/node/stopWatch.ts

22lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4export class StopWatch {
5 private startTime = process.hrtime();
6 private nanoSecondsInOneMilliSecond = 1000000;
7 private milliSecondsInOneSecond = 1000;
8
9 public stopAsMilliseconds(): number {
10 let ellapsedTime = process.hrtime(this.startTime);
11 let smallPartInNanoSeconds = ellapsedTime[1];
12 let smallPartInMilliSeconds = smallPartInNanoSeconds / this.nanoSecondsInOneMilliSecond;
13 let bigPartInSeconds = ellapsedTime[0];
14 let bigPartInMilliSeconds = bigPartInSeconds * this.milliSecondsInOneSecond;
15 let ellapsedTimeInMilliSeconds = bigPartInMilliSeconds + smallPartInMilliSeconds;
16 return ellapsedTimeInMilliSeconds;
17 }
18
19 public stopAsSeconds(): number {
20 return this.stopAsMilliseconds() / this.milliSecondsInOneSecond;
21 }
22}