bloomberg / pytest-memray

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

Ensure our histogram uses a non-zero step #113

Closed godlygeek closed 8 months ago

godlygeek commented 8 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 8 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 8 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 8 months ago

I think it's not intentional :S

OK, pushed a second commit that removes the spaces 😅