Skip to content

Add series and limit benchmarks with cache-aware variants - #125

Open
yuvraj707sharma wants to merge 1 commit into
sympy:masterfrom
yuvraj707sharma:add-series-benchmarks
Open

Add series and limit benchmarks with cache-aware variants#125
yuvraj707sharma wants to merge 1 commit into
sympy:masterfrom
yuvraj707sharma:add-series-benchmarks

Conversation

@yuvraj707sharma

Copy link
Copy Markdown

Includes cold-cache benchmarks that measure realistic first-call performance, since ASV runs in a loop and only reports warm-cache time. See: #111

References to other Issues or PRs

See #111
See sympy/sympy#21374

Brief description of what is fixed or changed

Add benchmarks for series expansions and limit computations.
No series or limit benchmarks existed before in this repo.

Includes cache-aware variants (TimeLimitColdCache) that call
clear_cache() before each measurement. This addresses the concern
raised in #111 that ASV loop-based timing only reports warm-cache
results, which can be misleading for SymPy operations.

Benchmarks added:

  • TimeLimitWarmCache: 4 limit benchmarks (standard)
  • TimeLimitColdCache: 4 limit benchmarks with cache clearing
  • TimeSeriesExpansion: 5 series benchmarks parameterized by order
  • TimeSeriesComposite: 3 composed expression benchmarks

AI Generation Disclosure

I used AI for initial guidance on the benchmark structure
and understanding the ASV format. The final code was written by me
after studying the existing benchmarks in this repo.

Includes cold-cache benchmarks that measure realistic first-call performance, since ASV runs in a loop and only reports warm-cache time. See: sympy#111
@mengChengxi

Copy link
Copy Markdown

Hello, @yuvraj707sharma
I think this is a useful attempt to make the cache effect more visible, but I have a concern about what is actually being measured here.

Right now clear_cache() is called inside each time_* method, so the benchmark time includes both clear_cache() and the actual SymPy operation. That means the reported number is not strictly the first-call cost of limit(...) itself.

On the other hand, if clear_cache() were moved to setup(), ASV would still run the benchmark function in an inner loop, so only the first iteration would really be cold and the later ones would already be warm again.

So this seems to expose a deeper limitation of expressing true cold-cache benchmarks in ASV, rather than just a small implementation detail. It still looks useful as a “cache-aware variant”, but I am not sure it can be interpreted as a strict first-call benchmark in its current form.

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.

2 participants