Skip to content

Commit 0b23a6d

Browse files
Wes Castrofacebook-github-bot
authored andcommitted
[TorchCodec] Add --output-results option to benchmark utility (#892)
Summary: Output the benchmarking results to a JSON file. Differential Revision: D82155925
1 parent fc60ed6 commit 0b23a6d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

benchmarks/decoders/benchmark_decoders.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import platform
1111
from pathlib import Path
12+
import json
1213

1314
import torch
1415

@@ -106,6 +107,12 @@ def main() -> None:
106107
default=False,
107108
action=argparse.BooleanOptionalAction,
108109
)
110+
parser.add_argument(
111+
"--output-json",
112+
help="Output the results to a JSON file",
113+
type=str,
114+
default="",
115+
)
109116

110117
args = parser.parse_args()
111118
specified_decoders = set(args.decoders.split(","))
@@ -146,6 +153,10 @@ def main() -> None:
146153
min_runtime_seconds=args.min_run_seconds,
147154
benchmark_video_creation=args.bm_video_creation,
148155
)
156+
if args.output_json:
157+
with open(args.output_json, "w") as f:
158+
json.dump(results, f, indent=2)
159+
149160
data = {
150161
"experiments": results,
151162
"system_metadata": {

0 commit comments

Comments
 (0)