Skip to content

[repo-assist] perf: add AggressiveInlining to Square; add Add/Subtract/FromDecimal benchmarks - #215

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/perf-add-sub-benchmarks-2026-07-06-5515e79bd7618809
Draft

[repo-assist] perf: add AggressiveInlining to Square; add Add/Subtract/FromDecimal benchmarks#215
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/perf-add-sub-benchmarks-2026-07-06-5515e79bd7618809

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Two small, targeted improvements to the main branch:

  1. [MethodImpl(MethodImplOptions.AggressiveInlining)] on Square
  2. New benchmarks for Add, Subtract, and FromDecimal

Changes

src/FixedPointNano/FixedPointNano.cs

SquareAggressiveInlining

Square is a single-expression wrapper around operator *:

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static FixedPointNano Square(FixedPointNano value) => value * value;

It was the only short arithmetic helper without the attribute. The hint allows the JIT to eliminate the call frame when Square appears in a hot loop (e.g. Bollinger band accumulation).

benchmarks/FixedPointNano.Benchmarks/FixedPointNanoMathBenchmarks.cs

Added 7 benchmarks:

Benchmark Measures
AddRaw FixedPointNano + FixedPointNano
AddDecimalReference decimal + decimalFromDecimal
AddDoubleReference double + double
SubtractRaw FixedPointNano - FixedPointNano
SubtractDecimalReference decimal - decimalFromDecimal
SubtractDoubleReference double - double
FromDecimalRaw Fpn.FromDecimal(decimal) in isolation

Addition and subtraction are the most frequently executed operations in accumulation loops — yet had no isolated benchmark. FromDecimal was only measured as part of the decimal-reference paths, never directly.

Trade-offs

  • AggressiveInlining on Square carries a marginal code-size cost at large call-sites, but the method body is a single multiplication — well within typical inlining size limits.
  • The new benchmarks add ~40 lines to the benchmark file; all are consistent with the existing style.

Test Status

dotnet build FixedPointNano.slnx -c Release
Build succeeded. 0 Warning(s), 0 Error(s)

dotnet test tests/FixedPointNano.Tests -c Release
Passed! - Failed: 0, Passed: 1426, Skipped: 0, Total: 1426

Build: ✅ Tests: ✅ (1426 passing, 0 failures)

Generated by 🤖 Repo Assist — workflow run.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@e15e57b40918dbca11b350c55d02ab61934afa75

…benchmarks

FixedPointNano.cs:
- Add [MethodImpl(MethodImplOptions.AggressiveInlining)] to Square(). The
  method is a single-expression wrapper around operator * and is an obvious
  inlining candidate on hot arithmetic paths.

FixedPointNanoMathBenchmarks.cs:
- Add AddRaw / AddDecimalReference / AddDoubleReference benchmarks.
  Addition is the most-common operation in accumulation loops (e.g. SMA,
  VWAP) and was the only arithmetic operator without an isolated benchmark.
- Add SubtractRaw / SubtractDecimalReference / SubtractDoubleReference —
  same gap for subtraction.
- Add FromDecimalRaw — benchmarks the direct decimal construction path,
  complementing the existing FromDoubleRaw benchmark.

All 1426 existing tests continue to pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants