Skip to content

Conversation

Erotemic
Copy link
Member

@Erotemic Erotemic commented Aug 10, 2025

Adding onto #376 to start to measure the amount of overhead line-profiler adds as a function of python version and line-profiler version (and other factors).

The idea is to have a script that can generate a report for a specific style of benchmarks, then multiple of these result files can be aggregated to view statistics over different contexts in which the benchmarks are run. This way we can slice/dice the numbers in a way to gain more insight.

This is VERY rough right now (hard coded paths and whatnot), but I have the initial proof of concept, which shows the impact of the changes in #376

These also rely on some of my utility libraries: scriptconfig / kwutil /ubelt.

Plot aggregating all versions of python the tests are run against:

regression_plot

Plot splitting out by python versions:

regression_plot_pyversions

It looks like the sys.monitoring adds quite a bit more overhead than the legacy way of handling the trace callbacks, but in all cases @376 does seem to be a speed improvement.

The jump up from 4.0 to 4.1 is stark, I'm wondering what's happening there or maybe there is a mistake in my benchmark script. I do think the code I wrote here can serve as a decent launch point to get an automated way of measuring how we are doing on overhead and if new patches are causing significant regressions or not.

@Theelx
Copy link
Collaborator

Theelx commented Aug 10, 2025

That looks nice! One suggestion I have would be to make use of pytest-benchmark and its pytest-benchmark[histogram] addon (though it doesn't make those nice plots by default, that can be implemented on top of its data). This is what I was planning to do for regression tests, and I have an example script making use of it at jsonpickle's repository and run instructions here. Sample output is included in the attached pictures. Also, I don't think this took into account my most recent commit for fixing your GPT review suggestions 2 and 4 over on #376.

image image

@Erotemic Erotemic changed the title [WIP] Theelx main with benchmarks poc [WIP] Benchmarks POC Aug 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants