-
Notifications
You must be signed in to change notification settings - Fork 2
/
examples.js
46 lines (36 loc) · 1 KB
/
examples.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const elapsed = require("./lib/cjs");
// const chalk = require('chalk');
elapsed.start('test2');
setTimeout(()=>{
elapsed.end('test2');
}, 1300);
elapsed.start('test');
setTimeout(()=>{
elapsed.end('test');
}, 1300);
elapsed.start('testoverride');
setTimeout(()=>{
elapsed.end('testoverride', 'override label');
}, 100);
elapsed.start('vlad');
setTimeout(()=>{
const test = elapsed.get('vlad');
console.log(test);
}, 1200);
// ElapsedLogger is similliar to console.time() & console.timeEnd()
elapsed.start('label');
elapsed.start('timer label');
setTimeout(()=>{
elapsed.end('label');
elapsed.end('timer label');
}, 800);
// or use ElapsedLogger as an instance (recommended)
const elapsedTimer = elapsed.start();
// const elapsedTimer2 = elapsed.start();
console.log('smth');
setTimeout(()=>{
const t = elapsedTimer.get();
console.log(t);
// elapsedTimer2.end(chalk.green('you can use colors here, try chalk or colors packages:'));
elapsedTimer.end('finished:');
}, 800);