Add trace_analysis_script/src/trace_analysis_script/cli.py
This commit is contained in:
parent
7c6880e2ad
commit
f9f7dcc40a
1 changed files with 47 additions and 0 deletions
47
trace_analysis_script/src/trace_analysis_script/cli.py
Normal file
47
trace_analysis_script/src/trace_analysis_script/cli.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from trace_analysis_script.core import analyze_trace
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Analyse von Kernel-Trace-Daten zur Bestimmung von Offset- und EM-Statistiken."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--input",
|
||||
required=True,
|
||||
help="Pfad zur Trace-Datei im CSV-Format."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--output",
|
||||
required=True,
|
||||
help="Pfad zur Ausgabedatei im JSON-Format."
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
input_path = Path(args.input)
|
||||
output_path = Path(args.output)
|
||||
|
||||
if not input_path.exists():
|
||||
print(f"Fehler: Eingabedatei {input_path} wurde nicht gefunden.", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
result = analyze_trace(str(input_path))
|
||||
except Exception as e:
|
||||
print(f"Analysefehler: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
output_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with output_path.open("w", encoding="utf-8") as f:
|
||||
json.dump(result, f, indent=2)
|
||||
print(f"Analyse abgeschlossen. Ergebnisse gespeichert unter: {output_path}")
|
||||
except Exception as e:
|
||||
print(f"Fehler beim Schreiben der Ausgabe: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Reference in a new issue