@@ -15,35 +15,6 @@ if (['default', 'csv', 'silent'].indexOf(outputFormat) == -1) {
1515
1616exports . PORT = process . env . PORT || 12346 ;
1717
18- // If this is the main module, then run the benchmarks
19- if ( module === require . main ) {
20- var type = process . argv [ 2 ] ;
21- var testFilter = process . argv [ 3 ] ;
22- if ( ! type ) {
23- console . error ( 'usage:\n ./node benchmark/common.js <type> [testFilter]' ) ;
24- process . exit ( 1 ) ;
25- }
26-
27- var dir = path . join ( __dirname , type ) ;
28- var tests = fs . readdirSync ( dir ) ;
29-
30- if ( testFilter ) {
31- var filteredTests = tests . filter ( function ( item ) {
32- if ( item . lastIndexOf ( testFilter ) >= 0 ) {
33- return item ;
34- }
35- } ) ;
36-
37- if ( filteredTests . length === 0 ) {
38- console . error ( '%s is not found in \n %j' , testFilter , tests ) ;
39- return ;
40- }
41- tests = filteredTests ;
42- }
43-
44- runBenchmarks ( ) ;
45- }
46-
4718function hasWrk ( ) {
4819 var result = child_process . spawnSync ( 'wrk' , [ '-h' ] ) ;
4920 if ( result . error && result . error . code === 'ENOENT' ) {
@@ -53,31 +24,6 @@ function hasWrk() {
5324 }
5425}
5526
56- function runBenchmarks ( ) {
57- var test = tests . shift ( ) ;
58- if ( ! test )
59- return ;
60-
61- if ( test . match ( / ^ [ \. _ ] / ) )
62- return process . nextTick ( runBenchmarks ) ;
63-
64- if ( outputFormat == 'default' )
65- console . error ( type + '/' + test ) ;
66-
67- test = path . resolve ( dir , test ) ;
68-
69- var a = ( process . execArgv || [ ] ) . concat ( test ) ;
70- var child = child_process . spawn ( process . execPath , a , { stdio : 'inherit' } ) ;
71- child . on ( 'close' , function ( code ) {
72- if ( code ) {
73- process . exit ( code ) ;
74- } else {
75- console . log ( '' ) ;
76- runBenchmarks ( ) ;
77- }
78- } ) ;
79- }
80-
8127exports . createBenchmark = function ( fn , options ) {
8228 return new Benchmark ( fn , options ) ;
8329} ;
@@ -262,4 +208,3 @@ exports.v8ForceOptimization = function(method, ...args) {
262208 method . apply ( null , args ) ;
263209 return eval ( '%GetOptimizationStatus(method)' ) ;
264210} ;
265-
0 commit comments