in pytext/utils/timing.py [0:0]
def report(self, report_pep=False):
snapshot_total = timeit.default_timer() - self.start
def path(key):
return " -> ".join(label for label, _ in key)
def print_pep(results, snapshot_total):
for key, times in sorted(self.times.items()):
if path(key) == "evaluate -> pytorch eval once":
info = {
"type": path(key),
"metric": "latency",
"unit": "ms",
"value": f"{times.average * 1000:.1f}",
}
print("PyTorchObserver " + json_dumps(info))
if len(self.times) == 0:
print(
"Note: Nothing was reported. "
'Please use timing.time("foo") to measure time.'
)
return
results = [
{
"name": path(key),
"total": format_time(times.sum),
"avg": format_time(times.average),
"max": format_time(times.max),
"p50": format_time(times.p50),
"p90": format_time(times.p90),
"p99": format_time(times.p99),
"count": times.count,
}
for key, times in sorted(self.times.items())
]
print(
ascii_table(
results,
human_column_names={
"name": "Stage",
"total": "Total",
"avg": "Average",
"max": "Max",
"p50": "P50",
"p90": "P90",
"p99": "P99",
"count": "Count",
},
footer={"name": "Total time", "total": format_time(snapshot_total)},
alignments={"name": "<"},
)
)
if report_pep:
print_pep(results, snapshot_total)