Add trace_analysis/src/trace_analysis/cli.py

This commit is contained in:
Mika 2026-01-13 11:17:04 +00:00
parent 3ff2cc3c32
commit 4c58dd1bbe

View file

@ -0,0 +1,30 @@
import argparse
import json
from pathlib import Path
from trace_analysis import core
def main():
"""Command-line interface to run trace analysis."""
parser = argparse.ArgumentParser(description="Analyze CPU migration trace data.")
parser.add_argument(
"--input",
required=True,
help="Path to the JSON input file with trace data."
)
args = parser.parse_args()
input_path = Path(args.input)
if not input_path.exists():
raise FileNotFoundError(f"Input file not found: {input_path}")
with input_path.open("r", encoding="utf-8") as f:
trace_data = json.load(f)
# Analyze trace data using the core module
result = core.analyze_trace(trace_data)
# Print results as formatted JSON
print(json.dumps(result, indent=2, ensure_ascii=False))
if __name__ == "__main__":
main()