MCPcopy
hub / github.com/cilium/cilium / calcDiffRecords

Function calcDiffRecords

tools/complexity-diff/main.go:274–337  ·  view source on GitHub ↗
(oldRecords, newRecords map[string]verifierComplexityRecord, onlyChange bool)

Source from the content-addressed store, hash-verified

272}
273
274func calcDiffRecords(oldRecords, newRecords map[string]verifierComplexityRecord, onlyChange bool) []verifierComplexityRecord {
275 diffRecords := make([]verifierComplexityRecord, 0)
276 for _, key := range slices.Sorted(maps.Keys(newRecords)) {
277 newRecord := newRecords[key]
278 oldRecord, ok := oldRecords[key]
279 if !ok {
280 if onlyChange {
281 continue
282 }
283
284 diffRecords = append(diffRecords, newRecord)
285 continue
286 }
287
288 diffRecords = append(diffRecords, verifierComplexityRecord{
289 Kernel: newRecord.Kernel,
290 Collection: newRecord.Collection,
291 Build: newRecord.Build,
292 Load: newRecord.Load,
293 Program: newRecord.Program,
294
295 InsnsProcessed: newRecord.InsnsProcessed - oldRecord.InsnsProcessed,
296 InsnsLimit: newRecord.InsnsLimit - oldRecord.InsnsLimit,
297 MaxStatesPerInsn: newRecord.MaxStatesPerInsn - oldRecord.MaxStatesPerInsn,
298 TotalStates: newRecord.TotalStates - oldRecord.TotalStates,
299 PeakStates: newRecord.PeakStates - oldRecord.PeakStates,
300 MarkRead: newRecord.MarkRead - oldRecord.MarkRead,
301
302 VerificationTimeMicroseconds: newRecord.VerificationTimeMicroseconds - oldRecord.VerificationTimeMicroseconds,
303 StackDepth: newRecord.StackDepth - oldRecord.StackDepth,
304
305 MapCount: newRecord.MapCount - oldRecord.MapCount,
306 })
307 }
308
309 if !onlyChange {
310 for key, oldRecord := range oldRecords {
311 _, ok := newRecords[key]
312 if !ok {
313 diffRecords = append(diffRecords, verifierComplexityRecord{
314 Kernel: oldRecord.Kernel,
315 Collection: oldRecord.Collection,
316 Build: oldRecord.Build,
317 Load: oldRecord.Load,
318 Program: oldRecord.Program,
319
320 InsnsProcessed: -oldRecord.InsnsProcessed,
321 InsnsLimit: -oldRecord.InsnsLimit,
322 MaxStatesPerInsn: -oldRecord.MaxStatesPerInsn,
323 TotalStates: -oldRecord.TotalStates,
324 PeakStates: -oldRecord.PeakStates,
325 MarkRead: -oldRecord.MarkRead,
326
327 VerificationTimeMicroseconds: -oldRecord.VerificationTimeMicroseconds,
328 StackDepth: -oldRecord.StackDepth,
329
330 MapCount: -oldRecord.MapCount,
331 })

Callers 1

mainFunction · 0.85

Calls 1

KeysMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…