@@ -18,12 +18,22 @@ import {
1818} from './driver.mjs' ;
1919
2020const __dirname = import . meta. dirname ;
21- const alphabetically = ( a : string , b : string ) => String . prototype . localeCompare . call ( a , b ) ;
21+
22+ export const alphabetically = ( a : unknown , b : unknown ) => {
23+ const res = `${ a } ` . localeCompare ( `${ b } ` , 'en-US' , {
24+ usage : 'sort' ,
25+ numeric : true ,
26+ ignorePunctuation : false
27+ } ) ;
28+ return res < 0 ? - 1 : res > 0 ? 1 : 0 ;
29+ } ;
2230
2331/** Find every mjs file in the suites folder */
24- async function getBenchmarks ( ) : Promise <
25- Record < string , Record < string , { benchFile : string } & Record < string , any > > >
26- > {
32+ async function getBenchmarks ( ) : Promise < {
33+ tests : Record < string , Record < string , { benchFile : string } & Record < string , any > > > ;
34+ total : number ;
35+ } > {
36+ let total = 0 ;
2737 const tests : Record <
2838 string ,
2939 Record < string , { benchFile : string } & Record < string , any > >
@@ -39,15 +49,21 @@ async function getBenchmarks(): Promise<
3949 if ( ! benchmark . endsWith ( '.mjs' ) ) continue ;
4050 tests [ suite ] ??= Object . create ( null ) ;
4151 tests [ suite ] [ benchmark ] = { benchFile : path . join ( 'suites' , suite , benchmark ) } ;
52+ total += 1 ;
4253 }
4354 }
44- return tests ;
55+ return { tests, total } ;
4556}
4657
4758const hw = os . cpus ( ) ;
4859const ram = os . totalmem ( ) / 1024 ** 3 ;
4960const platform = { name : hw [ 0 ] . model , cores : hw . length , ram : `${ ram } GB` } ;
5061
62+ const { tests, total } = await getBenchmarks ( ) ;
63+
64+ const earliest = new Date ( Date . now ( ) + total * 60 * 1000 ) ; // plus one min per bench
65+ const latest = new Date ( Date . now ( ) + total * 6 * 60 * 1000 ) ; // plus six min per bench (if we overshoot the 5 min limit)
66+
5167const systemInfo = ( ) =>
5268 [
5369 `\n- cpu: ${ platform . name } ` ,
@@ -56,14 +72,15 @@ const systemInfo = () =>
5672 `- os: ${ process . platform } (${ os . release ( ) } )` ,
5773 `- ram: ${ platform . ram } ` ,
5874 `- node: ${ process . version } ` ,
75+ `- running ${ total } benchmarks` ,
76+ ` - finishes soonest: ${ earliest . toLocaleTimeString ( 'en-US' , { timeZoneName : 'short' } ) } latest ${ latest . toLocaleTimeString ( 'en-US' , { timeZoneName : 'short' } ) } ` ,
5977 `- driver: ${ MONGODB_DRIVER_VERSION } (${ MONGODB_DRIVER_REVISION } ): ${ MONGODB_DRIVER_PATH } ` ,
6078 ` - options ${ util . inspect ( MONGODB_CLIENT_OPTIONS ) } ` ,
6179 `- bson: ${ MONGODB_BSON_VERSION } (${ MONGODB_BSON_REVISION } ): (${ MONGODB_BSON_PATH } )\n`
6280 ] . join ( '\n' ) ;
6381
6482console . log ( systemInfo ( ) ) ;
6583
66- const tests = await getBenchmarks ( ) ;
6784const runnerPath = path . join ( __dirname , 'runner.mjs' ) ;
6885
6986const results = [ ] ;
0 commit comments