MCPcopy
hub / github.com/unkeyed/unkey / BenchmarkComparison

Function BenchmarkComparison

pkg/uid/benchmark_test.go:14–21  ·  view source on GitHub ↗

BenchmarkComparison compares the performance of the optimized New() vs the original. This benchmark demonstrates the performance improvements achieved through: - Cached timestamps via go-timecache to avoid time.Now() syscalls - Using github.com/mr-tron/base58 instead of custom implementation - Effic

(b *testing.B)

Source from the content-addressed store, hash-verified

12// - Using github.com/mr-tron/base58 instead of custom implementation
13// - Efficient string building without fmt.Sprintf
14func BenchmarkComparison(b *testing.B) {
15 b.Run("New_Optimized", func(b *testing.B) {
16 b.ReportAllocs()
17 for i := 0; i < b.N; i++ {
18 _ = uid.New(uid.KeyPrefix)
19 }
20 })
21}
22
23// BenchmarkNew benchmarks the optimized New() implementation with different configurations.
24func BenchmarkNew(b *testing.B) {

Callers

nothing calls this directly

Calls 2

NewFunction · 0.92
RunMethod · 0.65

Tested by

no test coverage detected