Add trace_analysis/src/trace_analysis/cli.py
This commit is contained in:
parent
3ff2cc3c32
commit
4c58dd1bbe
1 changed files with 30 additions and 0 deletions
30
trace_analysis/src/trace_analysis/cli.py
Normal file
30
trace_analysis/src/trace_analysis/cli.py
Normal 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()
|
||||
Loading…
Reference in a new issue