Array Querying Benchmarks in C#
A performance comparison project to evaluate the efficiency of different data structure representations in C#. Specifically, this project compares the memory usage and access speed between a List of Structures (ListOfStructures
) and a Structure of Lists (StructureOfList
).
Table of Contents
How it Works
What it Does
The project contains two primary data structure representations:
ListOfStructures
: AnIList
implementation that wraps around aList<Order>
whereOrder
is a custom structure.StructureOfList
: A read-only list that stores individual properties of `Order` in separate arrays (int[]
,string[]
, etc.).
Using BenchmarkDotNet, it performs benchmark tests that measure the speed and memory performance for querying these data structures with LINQ and explicit loops.
What is its Objective
The main objectives are:
- To compare memory usage for the different data structure representations.
- To compare data access speeds for the different data structure representations.
Requirements
- .NET Core 2.1 and above up to .NET 7.0
- BenchmarkDotNet package
Example Usage
Clone the repository and navigate to the project folder. Run the following command to start the benchmarking:
dotnet run -c Release --framework net7.0
This will execute the benchmark tests for the different runtimes (.NET Core 2.1, 3.1, .NET 5.0, .NET 6.0 and .NET 7.0) and output the results.
Contributing
- Fork the repository.
- Create your feature branch (
git checkout -b feature/fooBar
). - Commit your changes (
git commit -am 'Add some fooBar'
). - Push to the branch (
git push origin feature/fooBar
). - Create a new pull request.
License
This project is licensed under the MIT License - see the `LICENSE.md` file for details.