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)
| 12 | // - Using github.com/mr-tron/base58 instead of custom implementation |
| 13 | // - Efficient string building without fmt.Sprintf |
| 14 | func 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. |
| 24 | func BenchmarkNew(b *testing.B) { |