bloomberg / pytest-memray

pytest plugin for easy integration of memray memory profiler
https://pytest-memray.readthedocs.io/en/latest/
Apache License 2.0
323 stars 23 forks source link

Ensure our histogram uses a non-zero step #113

Closed godlygeek closed 4 months ago

godlygeek commented 4 months ago

When all allocations are the same size, we were falling back to the size of the smallest allocation as our step for generating histogram buckets. When the smallest allocation was zero bytes, that would lead to a division by zero and an exception.

Fix this by falling back to 1 instead of the size of the smallest allocation. This will never lead to a zero division error, and still puts every element in the same bucket because they're all equal (otherwise we wouldn't have needed the fallback).

Closes #93

godlygeek commented 4 months ago

Say @pablogsal - is it intentional that our histogram is space-separated? For 5 bins, we're printing:

▄   ▄ █ ▄

when I would have expected:

▄ ▄█▄
pablogsal commented 4 months ago

Say @pablogsal - is it intentional that our histogram is space-separated? For 5 bins, we're printing:

I think it's not intentional :S

godlygeek commented 4 months ago

I think it's not intentional :S

OK, pushed a second commit that removes the spaces 😅