Cysharp / Ulid

Fast .NET C# Implementation of ULID for .NET and Unity.
MIT License
1.33k stars 59 forks source link

Comparison with MassTransit.NewId #66

Open lucasteles opened 7 months ago

lucasteles commented 7 months ago

Is there any comparison with MassTransit.NewId?

jscarle commented 3 months ago

I benchmarked creating a couple of different unique identifiers as I was also curious:

BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3880/23H2/2023Update/SunValley3)
13th Gen Intel Core i7-13700KF, 1 CPU, 24 logical and 16 physical cores
.NET SDK 9.0.100-preview.6.24328.19
  [Host]     : .NET 9.0.0 (9.0.24.32707), X64 RyuJIT AVX2
  DefaultJob : .NET 9.0.0 (9.0.24.32707), X64 RyuJIT AVX2

| Method       | Mean     | Error    | StdDev   | Ratio | Gen0   | Allocated | Alloc Ratio |
|------------- |---------:|---------:|---------:|------:|-------:|----------:|------------:|
| Guid_Create  | 33.06 ns | 0.041 ns | 0.038 ns |  1.00 |      - |         - |          NA |
| Ulid_Create  | 25.91 ns | 0.047 ns | 0.044 ns |  0.78 |      - |         - |          NA |
| NUlid_Create | 77.44 ns | 0.106 ns | 0.094 ns |  2.34 | 0.0066 |     104 B |          NA |
| NewId_Create | 28.48 ns | 0.039 ns | 0.032 ns |  0.86 |      - |         - |          NA |