https://github.com/wellwind/js-multiple-stopwatch
A stopwatch tool let you measure the performance of your code. You can manage multiple stopwatches using this library.
https://github.com/wellwind/js-multiple-stopwatch
Last synced: about 1 year ago
JSON representation
A stopwatch tool let you measure the performance of your code. You can manage multiple stopwatches using this library.
- Host: GitHub
- URL: https://github.com/wellwind/js-multiple-stopwatch
- Owner: wellwind
- Created: 2016-05-13T13:50:29.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-23T07:26:29.000Z (about 10 years ago)
- Last Synced: 2024-10-12T10:13:23.329Z (over 1 year ago)
- Language: TypeScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# js-multiple-stopwatch.js
A stopwatch tool let you measure the performance of your code. You can manage multiple stopwatches using this library.
## Installation
```
npm install js-multiple-stopwatch
```
## Quick Start
Just see the code below to learn how to manage multiple stopwatches.
```javascript
var Stopwatch = require("js-multiple-stopwatch");
// start a stopwatch
Stopwatch.Tick();
var val = 0;
for (var i = 1; i <= 10; ++i) {
// using any name in parameter as stopwatch name
Stopwatch.Tick("iteration_" + i);
for (var j = 0; j < 1000000; ++j) {
val += j;
}
Stopwatch.Tock("iteration_" + i);
}
// stop a stopwatch
Stopwatch.Tock();
// using ElaspedTime to get execution time
for(var i = 1; i <= 10; ++i){
console.log("Iteration " + i + " Time : " + (Stopwatch.ElapsedTime("iteration_" + i) / 1000) + " seconde");
}
console.log("Total Time : " + (Stopwatch.ElapsedTime() / 1000) + " seconde");
```