bloomberg / memray

Memray is a memory profiler for Python
https://bloomberg.github.io/memray/
Apache License 2.0
13.17k stars 392 forks source link

tui: Use half-block characters for memory graph #504

Closed godlygeek closed 10 months ago

godlygeek commented 10 months ago

This is easier to read than our previous braille version, and looks nicer when rendered in a browser or VS Code. It's less granular, unfortunately. The braille version added a new dot for each ~6%, and this implementation adds a new half block for each ~11%.

This also fixes a longstanding bug: the graph was only showing half of the data points it should have been showing. Each data point would become the right braille column of one cell as well as the left braille column of the next cell, so we only had half the horizontal granularity we should have had.

godlygeek commented 10 months ago

In fixing the bug that caused two data points like 50, 100 to show up as

⠀⢸
⠀⢸
⢸⣿
⢸⣿

instead of as

⢸
⢸
⣿
⣿

I also removed some caching inside of MemoryGraph. It seemed like overkill, considering we're only dealing with 100 data points and 200 Unicode characters. If you object to removing the caching, though, I can re-add it - the trick will be that we need to bounce between two previously rendered versions, one for even ticks and one for odd ticks.

I think that's probably overkill, but I don't think it's hard to add if you want it.

codecov-commenter commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (1cce4cb) 92.30% compared to head (bc029c3) 92.27%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #504 +/- ## ========================================== - Coverage 92.30% 92.27% -0.03% ========================================== Files 91 91 Lines 11033 11030 -3 Branches 1524 1526 +2 ========================================== - Hits 10184 10178 -6 - Misses 844 847 +3 Partials 5 5 ``` | [Flag](https://app.codecov.io/gh/bloomberg/memray/pull/504/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg) | Coverage Δ | | |---|---|---| | [cpp](https://app.codecov.io/gh/bloomberg/memray/pull/504/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg) | `85.83% <ø> (-0.09%)` | :arrow_down: | | [python_and_cython](https://app.codecov.io/gh/bloomberg/memray/pull/504/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg) | `95.47% <100.00%> (-0.01%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=bloomberg#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.