Skip to content

Commit cf06dd7

Browse files
committed
feat: automatically log and report command time
1 parent b802f1d commit cf06dd7

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

esbmc_ai/__main__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import json
66
import logging
77
import sys
8+
from time import perf_counter
89

910
import argparse
1011

@@ -229,15 +230,22 @@ def main() -> None:
229230
except NotImplementedError:
230231
pass
231232

233+
start_time: float = perf_counter()
232234
result: CommandResult | None = command.execute()
235+
time_taken: float = perf_counter() - start_time
236+
logger.info(f"Time taken: {time_taken}")
237+
233238
if result:
234239
print(result)
235240
if config.use_json:
236-
json_result = result.to_json()
237-
print(json_result)
241+
json_result_str: str = result.to_json()
242+
json_result: dict = json.loads(json_result_str)
243+
json_result["time_taken_seconds"] = time_taken
244+
json_result_str = json.dumps(json_result)
245+
print(json_result_str)
238246
if config.json_path:
239247
with open(config.json_path, "w", encoding="utf-8") as f:
240-
f.write(json_result)
248+
f.write(json_result_str)
241249

242250
sys.exit(0)
243251
else:

esbmc_ai/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def on_set_addon_modules(cls, mods: list[str]) -> list[str]:
433433
)
434434

435435
json_path: Path | None = Field(
436-
default=Path("result.json"),
436+
default=None,
437437
validation_alias=_alias_choice("json_path"),
438438
description="The path to save the json output to.",
439439
)

0 commit comments

Comments
 (0)