Skip to content

Commit

Permalink
show large runtime differences in concise output
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Apr 25, 2023
1 parent 041ba12 commit bedddb7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions mypy_primer.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,27 @@ def header(self) -> str:
return ret

def format_concise(self) -> str:
runtime_diff = abs(self.new_result.runtime - self.old_result.runtime)
runtime_ratio = self.new_result.runtime / self.old_result.runtime
if runtime_ratio < 1:
speed = "faster"
runtime_ratio = 1 / runtime_ratio
else:
speed = "slower"

has_runtime_diff = runtime_diff > 1 and runtime_ratio > 1.1
if not self.diff and not has_runtime_diff:
return ""

ret = f"{self.project.name} ({self.project.location})"
if has_runtime_diff:
ret += (
f" got {runtime_ratio:.2f} {speed} "
f"({self.old_result.runtime:.1f}s -> {self.new_result.runtime:.1f}s)"
)
if self.diff:
return f"{self.project.name} ({self.project.location})\n{self.diff}"
return ""
ret += "\n" + self.diff
return ret

def format_diff_only(self) -> str:
ret = self.header()
Expand Down

0 comments on commit bedddb7

Please sign in to comment.