Skip to content

Commit

Permalink
Port the tree reporter to textual
Browse files Browse the repository at this point in the history
Now that we are using Textual for the live mode, we can port the tree
reporter to be a live Textual App. This has plenty of advantages over
the static version as it offers interactive exploration of the tree, as
well as the possibility of using different screens for showing detailed
information about allocations such as the source and metadata.

Signed-off-by: Pablo Galindo <[email protected]>
  • Loading branch information
pablogsal committed Nov 22, 2023
1 parent c4b35f3 commit 01f580a
Show file tree
Hide file tree
Showing 8 changed files with 4,397 additions and 718 deletions.
1 change: 1 addition & 0 deletions news/499.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Port the tree reporter to be an interactive Textual App.
13 changes: 0 additions & 13 deletions src/memray/commands/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
from pathlib import Path
from textwrap import dedent

from rich import print as rprint

from memray import FileReader
from memray._errors import MemrayCommandError
from memray._memray import size_fmt
from memray.commands.common import warn_if_not_enough_symbols
from memray.reporters.tree import TreeReporter

Expand Down Expand Up @@ -80,14 +77,4 @@ def run(self, args: argparse.Namespace, parser: argparse.ArgumentParser) -> None
f"Failed to parse allocation records in {result_path}\nReason: {e}",
exit_code=1,
)
print()
header = "Allocation metadata"
rprint(f"{header}\n{'-'*len(header)}")
rprint(f"Command line arguments: '{reader.metadata.command_line}'")
rprint(f"Peak memory size: {size_fmt(reader.metadata.peak_memory)}")
rprint(f"Number of allocations: {reader.metadata.total_allocations}")
print()
header = f"Biggest {args.biggest_allocs} allocations:"
rprint(header)
rprint("-" * len(header))
reporter.render()
Loading

0 comments on commit 01f580a

Please sign in to comment.