@@ -4,48 +4,56 @@ const addonName = path.basename(__filename, '.js');
44
55[ addonName , addonName + '_noexcept' ]
66 . forEach ( ( addonName ) => {
7- const rootAddon = require ( `./build/Release/${ addonName } ` ) ;
7+ const rootAddon = require ( 'bindings' ) ( {
8+ bindings : addonName ,
9+ module_root : __dirname
10+ } ) ;
11+ delete rootAddon . path ;
812 const implems = Object . keys ( rootAddon ) ;
13+ const maxNameLength =
14+ implems . reduce ( ( soFar , value ) => Math . max ( soFar , value . length ) , 0 ) ;
915 const anObject = { } ;
1016
11- console . log ( `${ addonName } : ` ) ;
17+ console . log ( `\n ${ addonName } : ` ) ;
1218
1319 console . log ( 'no arguments:' ) ;
1420 implems . reduce ( ( suite , implem ) => {
1521 const fn = rootAddon [ implem ] . noArgFunction ;
16- return suite . add ( implem , ( ) => fn ( ) ) ;
22+ return suite . add ( implem . padStart ( maxNameLength , ' ' ) , ( ) => fn ( ) ) ;
1723 } , new Benchmark . Suite )
1824 . on ( 'cycle' , ( event ) => console . log ( String ( event . target ) ) )
1925 . run ( ) ;
2026
2127 console . log ( 'one argument:' ) ;
2228 implems . reduce ( ( suite , implem ) => {
2329 const fn = rootAddon [ implem ] . oneArgFunction ;
24- return suite . add ( implem , ( ) => fn ( 'x' ) ) ;
30+ return suite . add ( implem . padStart ( maxNameLength , ' ' ) , ( ) => fn ( 'x' ) ) ;
2531 } , new Benchmark . Suite )
2632 . on ( 'cycle' , ( event ) => console . log ( String ( event . target ) ) )
2733 . run ( ) ;
2834
2935 console . log ( 'two arguments:' ) ;
3036 implems . reduce ( ( suite , implem ) => {
3137 const fn = rootAddon [ implem ] . twoArgFunction ;
32- return suite . add ( implem , ( ) => fn ( 'x' , 12 ) ) ;
38+ return suite . add ( implem . padStart ( maxNameLength , ' ' ) , ( ) => fn ( 'x' , 12 ) ) ;
3339 } , new Benchmark . Suite )
3440 . on ( 'cycle' , ( event ) => console . log ( String ( event . target ) ) )
3541 . run ( ) ;
3642
3743 console . log ( 'three arguments:' ) ;
3844 implems . reduce ( ( suite , implem ) => {
3945 const fn = rootAddon [ implem ] . threeArgFunction ;
40- return suite . add ( implem , ( ) => fn ( 'x' , 12 , true ) ) ;
46+ return suite . add ( implem . padStart ( maxNameLength , ' ' ) ,
47+ ( ) => fn ( 'x' , 12 , true ) ) ;
4148 } , new Benchmark . Suite )
4249 . on ( 'cycle' , ( event ) => console . log ( String ( event . target ) ) )
4350 . run ( ) ;
4451
4552 console . log ( 'four arguments:' ) ;
4653 implems . reduce ( ( suite , implem ) => {
4754 const fn = rootAddon [ implem ] . fourArgFunction ;
48- return suite . add ( implem , ( ) => fn ( 'x' , 12 , true , anObject ) ) ;
55+ return suite . add ( implem . padStart ( maxNameLength , ' ' ) ,
56+ ( ) => fn ( 'x' , 12 , true , anObject ) ) ;
4957 } , new Benchmark . Suite )
5058 . on ( 'cycle' , ( event ) => console . log ( String ( event . target ) ) )
5159 . run ( ) ;
0 commit comments