MCPcopy Create free account
hub / github.com/google/gapid / BenchmarkApproaches

Function BenchmarkApproaches

gapil/bapi/bapi_test.go:165–208  ·  view source on GitHub ↗

Times how long each of the following takes: * Parsing and resolving from source * Encoding the APIs * Decoding the APIs * Decompressing the encoded data with various compressors.

(b *testing.B)

Source from the content-addressed store, hash-verified

163// * Decoding the APIs
164// * Decompressing the encoded data with various compressors.
165func BenchmarkApproaches(b *testing.B) {
166 ctx := log.Testing(b)
167
168 var apis []*semantic.API
169 var mappings *semantic.Mappings
170
171 // Time how long it takes to parse and resolve the APIs from source
172 b.Run("Parse & Resolve", func(b *testing.B) {
173 for i := 0; i < b.N; i++ {
174 apis, mappings = resolveAPIs(ctx)
175 }
176 })
177
178 var data []byte
179
180 // Time how long it takes to encode
181 b.Run("Encode", func(b *testing.B) {
182 for i := 0; i < b.N; i++ {
183 var err error
184 data, err = bapi.Encode(apis, mappings)
185 check(err)
186 }
187 })
188
189 // Time how long it takes to decode
190 b.Run("Decode", func(b *testing.B) {
191 for i := 0; i < b.N; i++ {
192 _, _, err := bapi.Decode(data)
193 check(err)
194 }
195 })
196
197 // Compress using different compressors and measure the decompression time
198 for _, f := range compressors {
199 b.Run(f.name, func(b *testing.B) {
200 c := f.compress(data)
201 b.Log("Compressed size: ", len(c))
202 b.ResetTimer()
203 for i := 0; i < b.N; i++ {
204 f.decompress(c)
205 }
206 })
207 }
208}
209
210func resolveAPIs(ctx context.Context) ([]*semantic.API, *semantic.Mappings) {
211 apis := []*semantic.API{}

Callers

nothing calls this directly

Calls 8

resolveAPIsFunction · 0.85
checkFunction · 0.70
RunMethod · 0.65
EncodeMethod · 0.65
DecodeMethod · 0.65
compressMethod · 0.65
LogMethod · 0.65
decompressMethod · 0.65

Tested by

no test coverage detected