Skip to content

Benchmarks

Mykhailo Matviiv edited this page Jul 13, 2023 · 4 revisions

BenchmarkDotNet is used for all benchmarking done for this library. It's used extensively to make comparisons to competitors, as well as for benchmarking different approaches used in this library.

All benchmarks are reproducible and can be found in TypeId.Benchmarks project.

Comparison with competitor libraries

At the moment of writing, there are 2 more implementations of TypeId in .NET:

  1. TenCoKaciStromy/typeid-dotnet
  2. cbuctok/typeId

Benchmarks code can be found in TypeId.Benchmarks/LibraryComparison.

ID generation

In this benchmark, the TypeId is generated N times in a loop.

BenchmarkDotNet v0.13.6, Windows 11 (10.0.22621.1992/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X3D, 1 CPU, 32 logical and 16 physical cores
.NET SDK 6.0.412
  [Host]     : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
  DefaultJob : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
// Paste benchmarks here

ID parsing from string

In this benchmark, the TypeId is parsed from the string representation N times in a loop.

BenchmarkDotNet v0.13.6, Windows 11 (10.0.22621.1992/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X3D, 1 CPU, 32 logical and 16 physical cores
.NET SDK 6.0.412
  [Host]     : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
  DefaultJob : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
// Paste benchmarks here

ID serialization to string

In this benchmark, the TypeId is serialized to string N times in a loop.

BenchmarkDotNet v0.13.6, Windows 11 (10.0.22621.1992/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X3D, 1 CPU, 32 logical and 16 physical cores
.NET SDK 6.0.412
  [Host]     : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
  DefaultJob : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
// Paste benchmarks here

Common web-app query flow

This benchmark aims to simulate a common web-app query flow when data is retrieved from the database and returned in a JSON response. This flow involves:

  • Parsing the string representation of TypeId (retrieving from DB and mapping to .NET entity)
  • Serializing the TypeId instance to string (for JSON response).
BenchmarkDotNet v0.13.6, Windows 11 (10.0.22621.1992/22H2/2022Update/SunValley2)
AMD Ryzen 9 7950X3D, 1 CPU, 32 logical and 16 physical cores
.NET SDK 6.0.412
  [Host]     : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
  DefaultJob : .NET 6.0.20 (6.0.2023.32017), X64 RyuJIT AVX2
// Paste benchmarks here
Clone this wiki locally