benchmarking

A set of rules for measuring .NET performance with repeatable benchmarks. A benchmark is a controlled test that measures how quickly code runs and how much memory it uses.

In plain words
What is it for?
Use it to create BenchmarkDotNet micro-benchmarks, test performance regressions, prepare consistent release builds, and compare runtime or memory behavior.
Why use it?
It helps distinguish real performance changes from results caused by inconsistent test conditions. It also encourages tracking speed, memory use, and allocations over time.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/aaronontheweb/dotnet-cursor-rules/benchmarking
Clone the repo
git clone --depth 1 https://github.com/Aaronontheweb/dotnet-cursor-rules
Per session 8 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,579 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00008 $0.01579
Opus 5 $0.00004 $0.00790
Sonnet 5 $0.00002 $0.00316
Haiku 4.5 $0.00001 $0.00158

Measured 2d ago against content hash 5a37a30d68fc, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

benchmarking scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

benchmarking/benchmarking.mdc · 282 lines

How it starts

The opening of the file, as written. The whole thing — 282 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cursor Rules File: .NET Benchmarking Best Practices

This file provides guidelines for writing effective benchmarks using BenchmarkDotNet

and other performance testing tools.

Role Definition:

  • Performance Engineer
  • .NET Runtime Specialist
  • Optimization Expert

General: Description: > Performance testing and benchmarking should be systematic, reproducible, and provide meaningful insights. Use BenchmarkDotNet as the primary tool for micro-benchmarking and performance regression testing. Requirements: - Use BenchmarkDotNet for micro-benchmarks - Ensure consistent test environments - Follow scientific method - Track performance metrics over time - Consider memory and allocation patterns

Project Setup:

  • Configure benchmark projects:
    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net8.0</TargetFramework>
        <Configuration>Release</Configuration>
        <Optimize>true</Optimize>
        <DebugSymbols>false</DebugSymbols>
      </PropertyGroup>
      
      <ItemGroup>
        <PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
        <PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.13.10" 
            Condition="'$(OS)' == 'Windows_NT'" />
      </ItemGroup>
    </Project>
    

Benchmark Structure:

  • Basic benchmark setup:
    [MemoryDiagnoser]
    [RankColumn, MinColumn, MaxColumn, MeanColumn, MedianColumn]
    public class StringOperationsBenchmarks
    {
        private const string TestString = "Hello, World!";
        private readonly StringBuilder _builder = new();
        
        [Params(10, 100, 1000)]
        public int Iterations { get; set; }
        
        [GlobalSetup]
        public void Setup()
        {
            // Setup code that runs once before all benchmarks
        }
        
        [Benchmark(Baseline = true)]
        public string StringConcat()
        {
            var result = string.Empty;
            for (int i = 0; i < Iterations; i++)
                result += TestString;
            return result;
        }
        
        [Benchmark]
        public string StringBuilder()
        {
            _builder.Clear();
            for (int i = 0; i < Iterations; i++)
                _builder.Append(TestString);
            return _builder.ToString();
        }
    }
    

Read the full file on GitHub · 282 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 282 lines · 8 tokens per session scan A 5a37a30d68fc

Subscribe to this mod's changes

benchmarking is a cursor rule published in the GitHub repository Aaronontheweb/dotnet-cursor-rules (134 stars, last pushed 1y ago), licensed Apache-2.0. It adds 8 tokens to every session and 1,579 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.