Skip to content

Commit

Permalink
extract calculate_time_spent from print_time_report (#127362)
Browse files Browse the repository at this point in the history
Summary:
Fixes #ISSUE_NUMBER

wrap certain steps in a separate function for easier TTFB instrumentation (fb internal use case)

X-link: pytorch/pytorch#127362
Approved by: https://github.com/yanboliang, https://github.com/mengluy0125

Reviewed By: yanboliang, PaliC, mengluy0125

Differential Revision: D57889404

Pulled By: dshi7

fbshipit-source-id: d87091f0f1470c6235f532050f7d61edd0d43878
  • Loading branch information
dshi7 authored and facebook-github-bot committed May 31, 2024
1 parent d70dc8b commit 1dc4eee
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,9 @@ def increment_op_count(cnt):
op_count += cnt


# Print a report of time spent so far
# Ex:
# TIMING:
# entire_frame_compile:8.574629999999999
# backend_compile:5.26806
def print_time_report():
# Calculate total time spent so far for each phase
# For example, {'entire_frame_compile':8.574629999999999, 'backend_compile':5.26806}
def calculate_time_spent():
total = 0.0
total_by_key = {}
for timings in frame_phase_timing.values():
Expand All @@ -170,6 +167,17 @@ def print_time_report():
else:
total_by_key[key] += timing

return total_by_key


# Print a report of time spent so far
# Ex:
# TIMING:
# entire_frame_compile:8.574629999999999
# backend_compile:5.26806
def print_time_report():
total_by_key = calculate_time_spent()

out = "TIMING:"
for key, value in total_by_key.items():
out = f"{out} {key}:{round(value, 5)}"
Expand Down

0 comments on commit 1dc4eee

Please sign in to comment.