Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmarking project and remove empty array allocations #2284

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

karpinsn
Copy link

@karpinsn karpinsn commented Sep 4, 2024

  • This PR adds a CsvHelper.Benchmarks project to hold onto benchmarks for CsvHelper. This also adds a BenchmarkEnumerateRecords benchmark that benchmarks iterating through a CSV using csv.GetRecords()

  • This PR updates ObjectCreator.GetArgTypes to not allocate an empty Type[] when the passed in object array is empty. This helps reduce allocations by ~14% in the new BenchmarkEnumerateRecords benchmark.

Before

Method Mean Error StdDev Gen0 Gen1 Allocated
EnumerateRecords 2.951 ms 0.0576 ms 0.0640 ms 203.1250 15.6250 1.69 MB

image

After

Method Mean Error StdDev Gen0 Gen1 Allocated
EnumerateRecords 2.303 ms 0.0171 ms 0.0152 ms 171.8750 15.6250 1.46 MB

image

- This PR adds a CsvHelper.Benchmarks project to hold onto benchmarks
  for CsvHelper. This also adds a BenchmarkEnumerateRecords benchmark
  that benchmarks iterating through a CSV using csv.GetRecords()

- This PR updates ObjectCreator.GetArgTypes to not allocate an empty
  Type[] when the passed in object array is empty. This helps reduce
  allocations by ~14% in the new BenchmarkEnumerateRecords benchmark.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant