File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ class Benchmark {
19
19
this . _time = 0n ;
20
20
21
21
// Use the file name as the name of the benchmark
22
- this . name = require . main . filename . slice ( __dirname . length + 1 ) ;
22
+ // For esm, require.main is undefined so use options.filename
23
+ this . filename = options . filename || require . main ?. filename
24
+ this . name = this . filename . replace ( / .* \/ / , '' )
23
25
24
26
// Execution arguments i.e. flags used to run the jobs
25
27
this . flags = process . env . NODE_BENCHMARK_FLAGS ?. split ( / \s + / ) ?? [ ] ;
@@ -224,7 +226,7 @@ class Benchmark {
224
226
childArgs . push ( `${ key } =${ value } ` ) ;
225
227
}
226
228
227
- const child = child_process . fork ( require . main . filename , childArgs , {
229
+ const child = child_process . fork ( this . filename , childArgs , {
228
230
env : childEnv ,
229
231
execArgv : this . flags . concat ( process . execArgv ) ,
230
232
} ) ;
You can’t perform that action at this time.
0 commit comments