MCPcopy
hub / github.com/segmentio/ksuid / BenchmarkCompressedSet

Function BenchmarkCompressedSet

set_test.go:297–332  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

295}
296
297func BenchmarkCompressedSet(b *testing.B) {
298 ksuids1 := [1000]KSUID{}
299 ksuids2 := [1000]KSUID{}
300
301 for i := range ksuids1 {
302 ksuids1[i] = New()
303 }
304
305 ksuids2 = ksuids1
306 buf := make([]byte, 0, 1024)
307 set := Compress(ksuids2[:]...)
308
309 b.Run("write", func(b *testing.B) {
310 n := 0
311 for i := 0; i != b.N; i++ {
312 ksuids2 = ksuids1
313 buf = AppendCompressed(buf[:0], ksuids2[:]...)
314 n = len(buf)
315 }
316 b.SetBytes(int64(n + len(ksuids2)))
317 })
318
319 b.Run("read", func(b *testing.B) {
320 n := 0
321 for i := 0; i != b.N; i++ {
322 n = 0
323 for it := set.Iter(); true; {
324 if !it.Next() {
325 n++
326 break
327 }
328 }
329 }
330 b.SetBytes(int64((n * byteLength) + len(set)))
331 })
332}

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
CompressFunction · 0.85
AppendCompressedFunction · 0.85
IterMethod · 0.80
NextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…