haskell / criterion

A powerful but simple library for measuring the performance of Haskell code.
http://www.serpentine.com/criterion
BSD 2-Clause "Simplified" License
503 stars 86 forks source link

[FR] support benchmarking max memory usage #256

Closed NightMachinery closed 2 years ago

NightMachinery commented 2 years ago

Migrated from https://github.com/Gabriel439/bench/issues/45#issuecomment-1014904269 .

RyanGlScott commented 2 years ago

A place to start would be to record the max_mem_in_use_bytes from the RTSStats in the getStatistics function. Then you'd need to update the maximum in the addResults function. (If we start recording maximum values, however, the name addResults isn't really accurate anymore, since you wouldn't add two maximum values together.)

tbidne commented 2 years ago

Hi, what needs to be done here? I have this on a fork, and it seems to work as far as I can tell (work = field shows in the json output):

https://github.com/haskell/criterion/compare/master...tbidne:peak-allocated/

I'm happy to make a PR, though I'm not super familiar with criterion, so it's likely I could be missing something.

RyanGlScott commented 2 years ago

Thanks for working on this, @tbidne! Please do open a PR, as it would be more convenient to review the patch using the GitHub review UI. From a quick glance, your patch looks like what I was imagining it would be.

RyanGlScott commented 2 years ago

Fixed in #260.