Closed firenero closed 3 months ago
Thank you for your pull request. Unfortunately, the range syntax ([start .. end]) isn't supported when we target the .NET Framework. Can you use span.Slice(start, length) instead of the range syntax ?
Can you also do some benchmark comparing your code to the existing version, please ? You can use the project UUIDNext.Benchmarks for that
Sorry, I don't have .NET Framework so I couldn't test it. Updated the PR to use Slice()
.
I ran UuidBench.NewUuidV7()
benchmark using .NET 8 runtime against my changes and the main branch and got these results:
Method | Mean | Error | StdDev | Allocated |
---|---|---|---|---|
NewUuidV7 (new) | 100.4 ns | 2.00 ns | 1.67 ns | - |
NewUuidV7 (old) | 101.9 ns | 2.00 ns | 1.87 ns | - |
The diff is within the error which is somewhat expected given that the change only removes copying 6 bytes from stack allocated buffer. Unfortunately I can't run it against .NET Framework to see if results are different there.
I've done some benchmarks on the .NET framework and I get similar results: a few percent of improvement around the margin of error
PR Merged, thank you 👍
UUIDv7 generation utilizes an additional 8-bytes buffer for setting timestamp. This PR removes the need for additional buffer.
Changes: