Skip to content

Commit

Permalink
add renamed file
Browse files Browse the repository at this point in the history
  • Loading branch information
ayakayorihiro committed Dec 6, 2024
1 parent c14dcd2 commit 9e896cd
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tools/profiler/adjust-scaled-flame-svg.py
Original file line number Diff line number Diff line change
@@ -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("<title>"):
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)

0 comments on commit 9e896cd

Please sign in to comment.