This project contains performance benchmarks for the FSharp.Data library using BenchmarkDotNet.
ParseSimpleJson- Parse a small simple JSON documentParseNestedJson- Parse a nested JSON documentParseGitHubJson- Parse GitHub API response (~75KB)ParseTwitterJson- Parse Twitter API response (~74KB)ParseWorldBankJson- Parse World Bank API response (~20KB)ToStringGitHubJson- JSON parsing + ToString()ToStringTwitterJson- JSON parsing + ToString()
AccessProperties- Access JSON object propertiesGetArrayElements- Extract array elements from JSON
- Build the project in Release mode:
dotnet build -c Release
dotnet run -c Release# JSON parsing benchmarks only
dotnet run -c Release -- json
# JSON conversion benchmarks only
dotnet run -c Release -- conversions# Run only simple JSON parsing
dotnet run -c Release -- --filter "*ParseSimpleJson*"
# Run only GitHub JSON benchmarks
dotnet run -c Release -- --filter "*GitHub*"dotnet run -c Release -- --job dry --filter "*ParseSimpleJson*"BenchmarkDotNet will show:
- Mean: Average execution time per operation
- StdErr: Standard error of the mean
- Min/Max: Fastest and slowest execution times
- Memory: Memory allocations (when
[MemoryDiagnoser]is used)
Results are saved to BenchmarkDotNet.Artifacts/ folder.
These benchmarks provide baseline measurements for:
- JSON Parsing Performance: How fast can we parse different sizes/types of JSON?
- Memory Allocation: How much memory is allocated during operations?
- Regression Testing: Detect performance regressions in changes
- Optimization Validation: Measure impact of performance improvements
- Add new benchmark methods to existing classes or create new benchmark classes
- Mark methods with
[<Benchmark>]attribute - Add
[<GlobalSetup>]for initialization if needed - Use
[<Params>]for parameterized benchmarks - Add appropriate diagnostics like
[<MemoryDiagnoser>]
Example:
[<Benchmark>]
member this.MyNewBenchmark() =
// Your code to benchmark here
SomeOperation()