joelverhagen / NCsvPerf

A test bench for various .NET CSV parsing libraries
https://www.joelverhagen.com/blog/2020/12/fastest-net-csv-parsers
MIT License
71 stars 14 forks source link

Fix clojure instantiation in loop #36

Closed leandromoh closed 3 years ago

leandromoh commented 3 years ago

This was pointed out by @MarkPflug in comment of #30.

This fix improved allocations from 345 MB to 261 MB (~ 24% less).
Performance was a bit improved too, since less instructions of instantiations are performed.


BenchmarkDotNet=v0.13.0, OS=Windows 10.0.18363.1440 (1909/November2019Update/19H2)
Intel Core i7-8650U CPU 1.90GHz (Kaby Lake R), 1 CPU, 8 logical and 4 physical cores
.NET SDK=5.0.104
  [Host]     : .NET 5.0.4 (5.0.421.11614), X64 RyuJIT
  DefaultJob : .NET 5.0.4 (5.0.421.11614), X64 RyuJIT
Method LineCount Mean Error StdDev Median Gen 0 Gen 1 Gen 2 Allocated
RecordParser 1000000 2.745 s 0.0541 s 0.0888 s 2.704 s 43000.0000 16000.0000 3000.0000 261 MB
CsvHelper 1000000 3.802 s 0.1026 s 0.2910 s 3.815 s 43000.0000 16000.0000 3000.0000 261 MB
Cursively 1000000 2.750 s 0.0502 s 0.0420 s 2.765 s 58000.0000 21000.0000 3000.0000 345 MB