File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed
Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const common = require ( '../common.js' ) ;
4+
5+ const bench = common . createBenchmark ( main , {
6+ n : [ 1 ] ,
7+ breakOnSigint : [ 0 , 1 ] ,
8+ withSigintListener : [ 0 , 1 ]
9+ } ) ;
10+
11+ const vm = require ( 'vm' ) ;
12+
13+ function main ( conf ) {
14+ const n = + conf . n ;
15+ const options = conf . breakOnSigint ? { breakOnSigint : true } : { } ;
16+ const withSigintListener = ! ! conf . withSigintListener ;
17+
18+ process . removeAllListeners ( 'SIGINT' ) ;
19+ if ( withSigintListener )
20+ process . on ( 'SIGINT' , ( ) => { } ) ;
21+
22+ var i = 0 ;
23+
24+ const contextifiedSandbox = vm . createContext ( ) ;
25+
26+ common . v8ForceOptimization ( vm . runInContext ,
27+ '0' , contextifiedSandbox , options ) ;
28+ bench . start ( ) ;
29+ for ( ; i < n ; i ++ )
30+ vm . runInContext ( '0' , contextifiedSandbox , options ) ;
31+ bench . end ( n ) ;
32+ }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ const common = require ( '../common.js' ) ;
4+
5+ const bench = common . createBenchmark ( main , {
6+ n : [ 1 ] ,
7+ breakOnSigint : [ 0 , 1 ] ,
8+ withSigintListener : [ 0 , 1 ]
9+ } ) ;
10+
11+ const vm = require ( 'vm' ) ;
12+
13+ function main ( conf ) {
14+ const n = + conf . n ;
15+ const options = conf . breakOnSigint ? { breakOnSigint : true } : { } ;
16+ const withSigintListener = ! ! conf . withSigintListener ;
17+
18+ process . removeAllListeners ( 'SIGINT' ) ;
19+ if ( withSigintListener )
20+ process . on ( 'SIGINT' , ( ) => { } ) ;
21+
22+ var i = 0 ;
23+
24+ common . v8ForceOptimization ( vm . runInThisContext , '0' , options ) ;
25+ bench . start ( ) ;
26+ for ( ; i < n ; i ++ )
27+ vm . runInThisContext ( '0' , options ) ;
28+ bench . end ( n ) ;
29+ }
You can’t perform that action at this time.
0 commit comments