csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

perf: prevent closure creation in `AttributeList`

Open TimothyMakkison opened this issue 2 months ago • 0 comments

Use static Func to prevent closure capture of context.

Benchmarks (Timing is inaccurate)

Saves memory for attribute heavy files aka test files.

Before

Method Mean Error StdDev Gen0 Gen1 Allocated
Default_CodeFormatter_Tests 161.1 ms 5.35 ms 15.53 ms 3000.0000 1000.0000 34.57 MB
Default_CodeFormatter_Complex 323.3 ms 9.19 ms 24.86 ms 5000.0000 2000.0000 53 MB

After

Method Mean Error StdDev Median Gen0 Gen1 Allocated
Default_CodeFormatter_Tests 134.6 ms 2.68 ms 7.06 ms 131.8 ms 3000.0000 1000.0000 34.4 MB
Default_CodeFormatter_Complex 283.3 ms 7.92 ms 22.97 ms 273.1 ms 5000.0000 2000.0000 53.01 MB

TimothyMakkison avatar Oct 29 '25 13:10 TimothyMakkison