report_analyzer.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python3
  2. """
  3. The tool used to analyze file created by "ya make ... --build-results-report <file>"
  4. """
  5. import argparse
  6. import sys
  7. import json
  8. if __name__ == "__main__":
  9. parser = argparse.ArgumentParser()
  10. parser.add_argument(
  11. "--report_file",
  12. help="path to file received via 'ya make ... --build-results-report <file>'",
  13. type=argparse.FileType("r"),
  14. required=True
  15. )
  16. parser.add_argument(
  17. "--summary_file",
  18. help="output file for summary",
  19. type=argparse.FileType("w"),
  20. default="-"
  21. )
  22. args = parser.parse_args()
  23. report_file = args.report_file
  24. summary_file = args.summary_file
  25. obj = json.load(report_file)
  26. all = []
  27. for result in obj["results"]:
  28. type_ = result["type"]
  29. if type_ == "test" and result.get("chunk"):
  30. rss_consumtion = result["metrics"].get("suite_max_proc_tree_memory_consumption_kb", 0) / 1024 / 1024
  31. path = result["path"] + " " + result.get("subtest_name", "")
  32. all.append((rss_consumtion, path))
  33. all.sort()
  34. summary_file.write("RSS usage by tests, sorted\n\n")
  35. for rss, path in all:
  36. summary_file.write("{} {:.2f} GiB\n".format(path, rss))
  37. summary_file.write("\n")