@@ -34,10 +34,12 @@ def add_engine(engine):
3434 os .path .join (SOURCE_ROOT , ".build/release/wasmkit-cli" ), "run" ,
3535 ]))
3636
37+ if shutil .which ("wasmtime" ):
38+ add_engine (SimpleEngine ("wasmtime" , ["wasmtime" , "run" , "-C" , "cache=n" ]))
39+ if shutil .which ("wasm3" ):
40+ add_engine (SimpleEngine ("wasm3" , ["wasm3" ]))
3741 if shutil .which ("wasmi_cli" ):
3842 add_engine (SimpleEngine ("wasmi" , ["wasmi_cli" ]))
39- if shutil .which ("wasmtime" ):
40- add_engine (SimpleEngine ("wasmtime" , ["wasmtime" ]))
4143 return engines
4244
4345
@@ -53,8 +55,10 @@ def __init__(self):
5355 self .path = os .path .join (
5456 SOURCE_ROOT , "Vendor" , "coremark" , "coremark.wasm" )
5557
56- def __call__ (self , runner , engine ):
57- engine (runner , self .path )
58+ def __call__ (self , runner , engines ):
59+ for engine_name , engine in engines .items ():
60+ print (f"===== Running { self .name } with { engine_name } =====" )
61+ engine (runner , self .path )
5862
5963
6064class WishYouWereFastBenchmark (Benchmark ):
@@ -74,26 +78,27 @@ def add_dir(subpath):
7478 add_dir ("libsodium" )
7579 self .targets = sorted (targets )
7680
77- def __call__ (self , runner , engine ):
81+ def __call__ (self , runner , engines ):
7882 # Save the result CSV file at ./results/{engine_name}/{target_name}.csv
7983 results_dir = runner .results_dir
80- runner .run_command ([
81- "mkdir" , "-p" , os .path .join (results_dir , engine .name )])
8284
8385 for i , target in enumerate (self .targets ):
84- print (f"===== Running { i + 1 } /{ len (self .targets )} : { target } =====" )
85- if not isinstance (engine , SimpleEngine ):
86- raise NotImplementedError (
87- "WishYouWereFastBenchmark only supports SimpleEngine" )
88-
89- csv_path = os .path .join (
90- results_dir , engine .name , os .path .basename (target ) + ".csv" )
91- command = engine .command (target )
92- command = [
93- "hyperfine" , "--warmup" , "5" , "--export-csv" , csv_path ,
94- " " .join (command )
95- ]
96- runner .run_command (command )
86+ for engine_name , engine in engines .items ():
87+ runner .run_command ([
88+ "mkdir" , "-p" , os .path .join (results_dir , engine .name )])
89+ print (f"===== Running { i + 1 } /{ len (self .targets )} : { target } with { engine_name } =====" )
90+ if not isinstance (engine , SimpleEngine ):
91+ raise NotImplementedError (
92+ "WishYouWereFastBenchmark only supports SimpleEngine" )
93+
94+ csv_path = os .path .join (
95+ results_dir , engine .name , os .path .basename (target ) + ".csv" )
96+ command = engine .command (target )
97+ command = [
98+ "hyperfine" , "--warmup" , "5" , "--export-csv" , csv_path ,
99+ " " .join (command )
100+ ]
101+ runner .run_command (command )
97102
98103
99104def available_benchmarks ():
@@ -147,10 +152,10 @@ def build(self):
147152 ])
148153
149154 def run (self ):
150- for engine_name , engine in sorted (self .engines .items (), key = lambda x : x [0 ]):
151- for benchmark_name , benchmark in self .benchmarks .items ():
152- print (f"===== Running { benchmark_name } with { engine_name } (ETA: { benchmark .eta_sec } sec) =====" )
153- benchmark (self , engine )
155+ engines = dict ( sorted (self .engines .items (), key = lambda x : x [0 ]))
156+ for benchmark_name , benchmark in self .benchmarks .items ():
157+ print (f"===== Running { benchmark_name } (ETA: { benchmark .eta_sec } sec) =====" )
158+ benchmark (self , engines )
154159
155160
156161def concat_results (args ):
@@ -159,8 +164,8 @@ def concat_results(args):
159164 results_dir = args .results_dir
160165 results = []
161166 original_header = None
162- for csv_path in glob .glob (os .path .join (results_dir , "** /*.csv" ), recursive = True ):
163- engine_name = csv_path .split ("/" )[1 ]
167+ for csv_path in glob .glob (os .path .join (results_dir , "*/*.csv" ), recursive = True ):
168+ engine_name = csv_path .split ("/" )[- 2 ]
164169 target_name = csv_path .split ("/" )[- 1 ].replace (".csv" , "" )
165170 with open (csv_path ) as f :
166171 lines = f .readlines ()
@@ -191,9 +196,11 @@ def main():
191196 parser .add_argument ("--step" , action = "append" , help = "Steps to run" ,
192197 choices = ["build" , "run" , "concat" ])
193198 parser .add_argument ("--results-dir" , help = "Directory to save results" ,
194- defaults = "./.build/results" )
199+ default = "./.build/results" )
195200
196201 args = parser .parse_args ()
202+ if args .step is None :
203+ args .step = ["build" , "run" , "concat" ]
197204
198205 runner = Runner (args , engines , benchmarks )
199206 if not args .skip_build and "build" in args .step :
0 commit comments