@@ -139,7 +139,8 @@ def main() -> int:
139139Examples:
140140 uv run python benchmarks/run_benchmarks.py --all
141141 uv run python benchmarks/run_benchmarks.py --validation --iterations 5000
142- uv run python benchmarks/run_benchmarks.py --all --json > results.json
142+ uv run python benchmarks/run_benchmarks.py --all --json
143+ uv run python benchmarks/run_benchmarks.py --output benchmark-results.json
143144 """ ,
144145 )
145146 parser .add_argument (
@@ -166,7 +167,14 @@ def main() -> int:
166167 parser .add_argument (
167168 "--json" ,
168169 action = "store_true" ,
169- help = "Output results as JSON" ,
170+ help = "Output results as JSON to stdout" ,
171+ )
172+ parser .add_argument (
173+ "--output" ,
174+ "-o" ,
175+ type = str ,
176+ metavar = "FILE" ,
177+ help = "Save JSON results to file" ,
170178 )
171179
172180 args = parser .parse_args ()
@@ -182,8 +190,13 @@ def main() -> int:
182190 print (f"\n Iterations: { args .iterations } " )
183191
184192 if args .all :
185- results = run_all_benchmarks (iterations = args .iterations , output_json = args .json )
186- if args .json :
193+ results = run_all_benchmarks (
194+ iterations = args .iterations , output_json = args .json or args .output
195+ )
196+ if args .output :
197+ Path (args .output ).write_text (json .dumps (results , indent = 2 ), encoding = "utf-8" )
198+ print (f"\n Results saved to: { args .output } " )
199+ elif args .json :
187200 print (json .dumps (results , indent = 2 ))
188201 elif args .validation :
189202 run_validation_benchmarks (iterations = args .iterations )
0 commit comments