File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+ const common = require ( '../common.js' ) ;
3
+ const url = require ( 'url' ) ;
4
+ const v8 = require ( 'v8' ) ;
5
+
6
+ const bench = common . createBenchmark ( main , {
7
+ type : 'one two' . split ( ' ' ) ,
8
+ n : [ 25e6 ]
9
+ } ) ;
10
+
11
+ function main ( conf ) {
12
+ const type = conf . type ;
13
+ const n = conf . n | 0 ;
14
+
15
+ const inputs = {
16
+ one : { slashes : true , host : 'localhost' } ,
17
+ two : { protocol : 'file:' , pathname : '/foo' } ,
18
+ } ;
19
+ const input = inputs [ type ] || '' ;
20
+
21
+ // Force-optimize url.format() so that the benchmark doesn't get
22
+ // disrupted by the optimizer kicking in halfway through.
23
+ for ( const name in inputs )
24
+ url . format ( inputs [ name ] ) ;
25
+
26
+ v8 . setFlagsFromString ( '--allow_natives_syntax' ) ;
27
+ eval ( '%OptimizeFunctionOnNextCall(url.format)' ) ;
28
+
29
+ bench . start ( ) ;
30
+ for ( var i = 0 ; i < n ; i += 1 )
31
+ url . format ( input ) ;
32
+ bench . end ( n ) ;
33
+ }
You can’t perform that action at this time.
0 commit comments