[repo-assist] perf: add [AggressiveInlining] to Frac and Lerp; add Lerp and Clamp benchmarks - #219
Draft
github-actions[bot] wants to merge 1 commit into
Conversation
…enchmarks - Frac was the only short hot-path helper lacking [AggressiveInlining]; its sibling FractionalPart (identical implementation) already has the attribute. - Lerp is a three-operation composable helper (start + (end-start) * amount) that benefits from inlining into call sites. - Add LerpDecimalReference, LerpDoubleReference, LerpRaw benchmarks. - Add ClampDecimalReference, ClampRaw benchmarks. These complete the coverage of the main public math helpers in the benchmark suite; only Pow, PopulationVariance/SampleVariance, and Parse remain. Tests: 1426/1426 passed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds
[MethodImpl(MethodImplOptions.AggressiveInlining)]to two public helpers that were missing it, and extends the benchmark suite with Lerp and Clamp measurements.Changes
src/FixedPointNano/FixedPointNano.csFrac: was the only short hot-path math helper without[AggressiveInlining]. Its siblingFractionalPart(identical implementation, different name) already carries the attribute. Adding it toFracmakes the two consistent.Lerp: a three-operation composable helper (start + (end-start) * amount). Like the arithmetic operators, it is short enough that inlining into hot loops avoids function-call overhead.benchmarks/FixedPointNano.Benchmarks/FixedPointNanoMathBenchmarks.csFive new benchmarks completing coverage of the main public math surface:
LerpDecimalReferencedecimalround-tripLerpDoubleReferencedouble(FP baseline)LerpRawFpn.Lerp— fixed-point pathClampDecimalReferenceMath.Clamp(decimal)round-tripClampRawFpn.Clamp— raw comparison pathClampis expected to be the fastest of all benchmarks: three raw comparisons with no arithmetic.Rationale
Consistent inlining hints reduce JIT overhead in tight loops. The benchmark additions let maintainers see exactly how these methods compare to the
decimalbaseline, consistent with every other math helper in the suite.Test Status
✅ Build succeeded — 0 warnings, 0 errors
✅ Tests passed — 1426/1426 (no behaviour change)
Add this agentic workflows to your repo
To install this agentic workflow, run