File tree Expand file tree Collapse file tree 5 files changed +126
-0
lines changed Expand file tree Collapse file tree 5 files changed +126
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var common = require ( '../common.js' ) ;
3+ var assert = require ( 'assert' ) ;
4+
5+ var bench = common . createBenchmark ( main , {
6+ thousands : [ 500 ] ,
7+ } ) ;
8+
9+ function main ( conf ) {
10+ var iterations = + conf . thousands * 1e3 ;
11+
12+ var timer = setTimeout ( ( ) => { } , 1 ) ;
13+ for ( var i = 0 ; i < iterations ; i ++ ) {
14+ setTimeout ( cb , 1 ) ;
15+ }
16+ var next = timer . _idlePrev ;
17+ clearTimeout ( timer ) ;
18+
19+ bench . start ( ) ;
20+
21+ for ( var j = 0 ; j < iterations ; j ++ ) {
22+ timer = next ;
23+ next = timer . _idlePrev ;
24+ clearTimeout ( timer ) ;
25+ }
26+
27+ bench . end ( iterations / 1e3 ) ;
28+ }
29+
30+ function cb ( ) {
31+ assert ( false , 'Timer should not call callback' ) ;
32+ }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var common = require ( '../common.js' ) ;
3+ var assert = require ( 'assert' ) ;
4+
5+ var bench = common . createBenchmark ( main , {
6+ thousands : [ 100 ] ,
7+ } ) ;
8+
9+ function main ( conf ) {
10+ var iterations = + conf . thousands * 1e3 ;
11+
12+ var timersList = [ ] ;
13+ for ( var i = 0 ; i < iterations ; i ++ ) {
14+ timersList . push ( setTimeout ( cb , i + 1 ) ) ;
15+ }
16+
17+ bench . start ( ) ;
18+ for ( var j = 0 ; j < iterations + 1 ; j ++ ) {
19+ clearTimeout ( timersList [ j ] ) ;
20+ }
21+ bench . end ( iterations / 1e3 ) ;
22+ }
23+
24+ function cb ( ) {
25+ assert ( false , 'Timer ' + this . _idleTimeout + ' should not call callback' ) ;
26+ }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var common = require ( '../common.js' ) ;
3+
4+ var bench = common . createBenchmark ( main , {
5+ thousands : [ 500 ] ,
6+ } ) ;
7+
8+ function main ( conf ) {
9+ var iterations = + conf . thousands * 1e3 ;
10+
11+ bench . start ( ) ;
12+
13+ for ( var i = 0 ; i < iterations ; i ++ ) {
14+ setTimeout ( ( ) => { } , 1 ) ;
15+ }
16+
17+ bench . end ( iterations / 1e3 ) ;
18+ }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var common = require ( '../common.js' ) ;
3+ var assert = require ( 'assert' ) ;
4+
5+ var bench = common . createBenchmark ( main , {
6+ thousands : [ 100 ] ,
7+ } ) ;
8+
9+ function main ( conf ) {
10+ var iterations = + conf . thousands * 1e3 ;
11+
12+ var timersList = [ ] ;
13+
14+ bench . start ( ) ;
15+ for ( var i = 0 ; i < iterations ; i ++ ) {
16+ timersList . push ( setTimeout ( cb , i + 1 ) ) ;
17+ }
18+ bench . end ( iterations / 1e3 ) ;
19+
20+ for ( var j = 0 ; j < iterations + 1 ; j ++ ) {
21+ clearTimeout ( timersList [ j ] ) ;
22+ }
23+ }
24+
25+ function cb ( ) {
26+ assert ( false , 'Timer ' + this . _idleTimeout + ' should not call callback' ) ;
27+ }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+ var common = require ( '../common.js' ) ;
3+
4+ var bench = common . createBenchmark ( main , {
5+ thousands : [ 500 ] ,
6+ } ) ;
7+
8+ function main ( conf ) {
9+ var iterations = + conf . thousands * 1e3 ;
10+ var count = 0 ;
11+
12+ for ( var i = 0 ; i < iterations ; i ++ ) {
13+ setTimeout ( cb , 1 ) ;
14+ }
15+
16+ bench . start ( ) ;
17+
18+ function cb ( ) {
19+ count ++ ;
20+ if ( count === iterations )
21+ bench . end ( iterations / 1e3 ) ;
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments