MCPcopy
hub / github.com/containerd/containerd / BenchmarkUnpackWithChainIDs

Function BenchmarkUnpackWithChainIDs

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

Source from the content-addressed store, hash-verified

66}
67
68func BenchmarkUnpackWithChainIDs(b *testing.B) {
69 // This simulates the new way of pre-calculating all chainIDs for every layer
70 // by calling `identity.ChainIDs` once.
71 unpackWithChainIDs := func(diffIDs []digest.Digest) {
72 chainIDs := make([]digest.Digest, len(diffIDs))
73 copy(chainIDs, diffIDs)
74 chainIDs = identity.ChainIDs(chainIDs)
75 for i := range diffIDs {
76 if i > 0 {
77 _ = chainIDs[i-1].String() // parent layer chainID
78 }
79 _ = chainIDs[i].String() // current layer chainID
80 }
81 if len(chainIDs) > 0 {
82 _ = chainIDs[len(chainIDs)-1].String()
83 }
84 }
85
86 numLayers := []int{5, 10, 25, 50}
87 for _, sz := range numLayers {
88 b.Run(fmt.Sprintf("num of layers: %d", sz), func(b *testing.B) {
89 diffIDs := generateRandomDiffIDs(b, sz)
90 for i := 0; i < b.N; i++ {
91 unpackWithChainIDs(diffIDs)
92 }
93 })
94 }
95}
96
97func TestBindToOverlay(t *testing.T) {
98 testCases := []struct {

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…