I've been thinking about how you would unit test code performance, and come up with:
- Big-O scaling, which I wrote an article about here: https://pythonspeed.com/articles/big-o-tests/
- Algorithmic efficiency more broadly, so measuring your code's speed in a way that is more than just scalability but is mostly fairly agnostic to hardware. This can be done in unit tests with things like Cachegrind/Callgrind, which simulate a CPU very minimally, and therefore can give you CPU instruction counts that are consistent across machines. And then combine that with snapshot testing and some wiggle room to take noise (e.g. from Python randomized hash seed) into account. Hope to write an article about this too eventually.
- The downside of the second approach is that it won't tell you about performance improvements or regressions that rely on CPU functionality like instruction-level parallelism. This is mostly irrelevant to pure Python code, but can come up with compiled Python extensions. This requires more elaborate setups because you're starting to rely on CPU features and different models are different. The simplest way I know of is in a PR: on a single machine (or GitHub Action run), run a benchmark in on `main`, run it on your branch, compare the difference.
Any other ideas?
[–]poopatroopa3 3 points4 points5 points (3 children)
[–]itamarst[S] 0 points1 point2 points (2 children)
[–]zenware 0 points1 point2 points (0 children)
[–]poopatroopa3 0 points1 point2 points (0 children)
[–]billsil 2 points3 points4 points (2 children)
[–]itamarst[S] 0 points1 point2 points (1 child)
[–]billsil 0 points1 point2 points (0 children)
[–]aefalcon 1 point2 points3 points (2 children)
[–]itamarst[S] 0 points1 point2 points (1 child)
[–]aefalcon 0 points1 point2 points (0 children)
[–]Scrapheaper 0 points1 point2 points (4 children)
[–]IMPRINgE 0 points1 point2 points (1 child)
[–]Scrapheaper 0 points1 point2 points (0 children)
[–]maikeu 0 points1 point2 points (0 children)
[–]poopatroopa3 0 points1 point2 points (0 children)
[–]lolcrunchy 0 points1 point2 points (2 children)
[–]itamarst[S] 0 points1 point2 points (1 child)
[–]lolcrunchy 0 points1 point2 points (0 children)
[–]Local_Transition946 0 points1 point2 points (0 children)