-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample.js
44 lines (32 loc) · 794 Bytes
/
example.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
suite('Finding a substring', function() {
benchmark('RegExp#test', function() {
/o/.test('Hello World!');
});
benchmark('String#indexOf', function() {
'Hello World!'.indexOf('o') > -1;
});
benchmark('String#match', function() {
!!'Hello World!'.match(/o/);
});
});
// Using promises
suite('Async timeout testing using promises', () => {
benchmark('100ms', () => {
return new Promise((resolve) => {
setTimeout(resolve, 100);
});
});
benchmark('200ms', () => {
return new Promise((resolve) => {
setTimeout(resolve, 200);
});
});
});
suite('Async timeout testing using callbacks', () => {
benchmark('100ms', (done) => {
setTimeout(done, 100);
});
benchmark('200ms', (done) => {
setTimeout(done, 200);
});
});