MCPcopy
hub / github.com/containerd/containerd / BenchmarkUnpackWithChainID

Function BenchmarkUnpackWithChainID

core/unpack/unpacker_test.go:44–66  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

42}
43
44func BenchmarkUnpackWithChainID(b *testing.B) {
45 // This simulates the old way of repeatedly calculating per-layer chainID
46 // as we unpack every layers, by calling `identity.ChainID`.
47 unpackWithChainID := func(diffIDs []digest.Digest) {
48 var chain []digest.Digest
49 for i := range diffIDs {
50 _ = identity.ChainID(chain) // parent layer chainID
51 chain = append(chain, diffIDs[i])
52 _ = identity.ChainID(chain).String() // current layer chainID
53 }
54 _ = identity.ChainID(chain).String()
55 }
56
57 numLayers := []int{5, 10, 25, 50}
58 for _, sz := range numLayers {
59 b.Run(fmt.Sprintf("num of layers: %d", sz), func(b *testing.B) {
60 diffIDs := generateRandomDiffIDs(b, sz)
61 for i := 0; i < b.N; i++ {
62 unpackWithChainID(diffIDs)
63 }
64 })
65 }
66}
67
68func BenchmarkUnpackWithChainIDs(b *testing.B) {
69 // This simulates the new way of pre-calculating all chainIDs for every layer

Callers

nothing calls this directly

Calls 3

generateRandomDiffIDsFunction · 0.85
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…