0.0.2 • Published 5 years ago
@26area/stop-watch v0.0.2
Simple Stop Watch
This is simple stop watch to measure performance by typescript.
Just,
import {StopWatch} from '@26area/stop-watch';
import {Duration} from '@26area/stop-watch';
import {sleep} from '@26area/stop-watch';
const stopWatch: StopWatch = StopWatch.start();
await sleep(1000);
const duration: Duration<undefined> = stopWatch.stop();
const durationInMillies: number = duration.getByMillis();
// durationInMillies is 1000
We can also measure function.
import {StopWatch} from '@26area/stop-watch';
import {Duration} from '@26area/stop-watch';
function foo(): number {
return 1;
}
async function fooAsync(): Promise<number> {
return 1;
}
const duration: Duration<number> = StopWatch.measure(() => foo());
duration.value;
// value is 1
const asyncDuration: Duration<number> = await StopWatch.measureAsync(() => fooAsync());
asyncDuration.value;
// value is 1
0.0.2
5 years ago
0.0.2-SNAPSHOT-4
5 years ago
0.0.2-SNAPSHOT-3
5 years ago
0.0.2-SNAPSHOT-2
5 years ago
0.0.2-SNAPSHOT-1
5 years ago
0.0.1
5 years ago
0.0.1-SNAPSHOT-1
5 years ago