Skip to content

Commit

Permalink
use 'pstats' not 'prof' for file extension and renderer option
Browse files Browse the repository at this point in the history
  • Loading branch information
MattiP authored and MattiP committed May 10, 2023
1 parent c5f39e8 commit cf84310
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions pyinstrument/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def dash_m_callback(option: str, opt: str, value: str, parser: optparse.OptionPa
action="store",
type="string",
help=(
"how the report should be rendered. One of: 'text', 'html', 'json', 'speedscope', 'prof', "
"how the report should be rendered. One of: 'text', 'html', 'json', 'speedscope', 'pstats', "
"or python import path to a renderer class. Defaults to the appropriate format "
"for the extension if OUTFILE is given, otherwise, defaults to 'text'."
),
Expand Down Expand Up @@ -456,7 +456,7 @@ def get_renderer_class(renderer: str) -> type[renderers.Renderer]:
return renderers.SpeedscopeRenderer
elif renderer == "session":
return renderers.SessionRenderer
elif renderer == "prof":
elif renderer == "pstats":
return renderers.PstatsRenderer
else:
try:
Expand All @@ -465,7 +465,7 @@ def get_renderer_class(renderer: str) -> type[renderers.Renderer]:
# ValueError means we failed to import this object
raise OptionsParseError(
f"Failed to find renderer with name {renderer!r}.\n"
"Options are text, html, json, speedscope, prof or a Python\n"
"Options are text, html, json, speedscope, pstats or a Python\n"
"import path to a Renderer class.\n"
"\n"
f"Underlying error: {err}\n"
Expand All @@ -488,8 +488,8 @@ def guess_renderer_from_outfile(outfile: str) -> str | None:
return "json"
elif ext == ".pyisession":
return "session"
elif ext == ".prof":
return "prof"
elif ext == ".pstats":
return "pstats"
else:
return None

Expand Down
2 changes: 1 addition & 1 deletion pyinstrument/renderers/pstatsrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PstatsRenderer(FrameRenderer):
suitable for processing by gprof2dot and snakeviz.
"""

output_file_extension = "prof"
output_file_extension = "pstats"
output_is_binary = True

def __init__(self, **kwargs: Any):
Expand Down
6 changes: 3 additions & 3 deletions test/test_pstats_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def profiler_session():


def test_pstats_renderer(profiler_session, tmp_path):
fname = tmp_path / "test.prof"
prof = PstatsRenderer().render(profiler_session)
fname = tmp_path / "test.pstats"
pstats = PstatsRenderer().render(profiler_session)
with open(fname, "w", encoding="utf-8", errors="surrogateescape") as fid:
fid.write(prof)
fid.write(pstats)
stats: Any = Stats(str(fname))
# Sanity check
assert stats.total_tt > 0
Expand Down

0 comments on commit cf84310

Please sign in to comment.