(b *testing.B)
| 66 | } |
| 67 | |
| 68 | func 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 | |
| 97 | func TestBindToOverlay(t *testing.T) { |
| 98 | testCases := []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…