From 9e896cd4242a6412d9a657d523b5ced380531f8d Mon Sep 17 00:00:00 2001 From: Ayaka Yorihiro Date: Fri, 6 Dec 2024 15:31:55 -0500 Subject: [PATCH] add renamed file --- tools/profiler/adjust-scaled-flame-svg.py | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tools/profiler/adjust-scaled-flame-svg.py diff --git a/tools/profiler/adjust-scaled-flame-svg.py b/tools/profiler/adjust-scaled-flame-svg.py new file mode 100644 index 000000000..f3845a2cb --- /dev/null +++ b/tools/profiler/adjust-scaled-flame-svg.py @@ -0,0 +1,31 @@ +import os +import sys + +# Takes in a flame graph svg that is scaled by 1000 and prints a version with fixed cycles. +def main(svg_in): + oin = open(svg_in, "r") + + for line in oin: + if line.startswith(""): + line_split = line.strip().split(" ") + target_idx = 0 + for i in range(len(line_split)): + if line_split[i] == "cycles,": + target_idx = i-1 + new_number = int(line_split[target_idx].split("(")[1].replace(",", "")) / 1000 + print(" ".join(line_split[0:target_idx]) + " (" + "{:,}".format(new_number) + " " + " ".join(line_split[target_idx+1:])) + else: + print(line.strip()) + + +if __name__ == "__main__": + if len(sys.argv) > 1: + svg_filename = sys.argv[1] + main(svg_filename) + else: + args_desc = [ + "INPUT_SVG" + ] + print(f"Usage: {sys.argv[0]} {' '.join(args_desc)}") + print("CELLS_JSON: Run the `component_cells` tool") + sys.exit(-1) \ No newline at end of file