MCPcopy
hub / github.com/cilium/cilium / main

Function main

tools/complexity-diff/main.go:36–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34}
35
36func main() {
37 if len(os.Args) != 4 {
38 panic("usage: complexity-diff <old> <new> <diff>")
39 }
40
41 oldFile := os.Args[1]
42 newFile := os.Args[2]
43 diffFile := os.Args[3]
44
45 oldRecords, err := loadRecords(oldFile)
46 if err != nil {
47 panic(err)
48 }
49 newRecords, err := loadRecords(newFile)
50 if err != nil {
51 panic(err)
52 }
53
54 diffRecords := calcDiffRecords(oldRecords, newRecords, true)
55
56 minMaxInsnsProcessed := calcMinMax(diffRecords, func(r verifierComplexityRecord) int {
57 return r.InsnsProcessed
58 })
59 printTop15MinMax("largest differences by instructions processed", minMaxInsnsProcessed, percentInsnsProcessed, colorRelativeChange)
60
61 minMaxStackDepth := calcMinMax(diffRecords, func(r verifierComplexityRecord) int {
62 return r.StackDepth
63 })
64 printTop15MinMax("largest differences by stack depth", minMaxStackDepth, percentStackDepth, colorRelativeChange)
65
66 minMaxMapCount := calcMinMax(diffRecords, func(r verifierComplexityRecord) int {
67 return r.MapCount
68 })
69 printTop15MinMax("largest differences by map count", minMaxMapCount, percentMapCount, colorRelativeChange)
70
71 var sortedNewRecords []verifierComplexityRecord
72 for _, key := range slices.Sorted(maps.Keys(newRecords)) {
73 sortedNewRecords = append(sortedNewRecords, newRecords[key])
74 }
75
76 minMaxInsnsProcessed = calcMinMax(sortedNewRecords, func(r verifierComplexityRecord) int {
77 return r.InsnsProcessed
78 })
79 printTop15MinMax("largest instructions processed", minMaxInsnsProcessed, percentInsnsProcessed, colorAbsoluteValueExponential)
80
81 minMaxStackDepth = calcMinMax(sortedNewRecords, func(r verifierComplexityRecord) int {
82 return r.StackDepth
83 })
84 printTop15MinMax("largest stack depth", minMaxStackDepth, percentStackDepth, colorAbsoluteValue)
85
86 minMaxMapCount = calcMinMax(sortedNewRecords, func(r verifierComplexityRecord) int {
87 return r.MapCount
88 })
89 printTop15MinMax("largest map count", minMaxMapCount, percentMapCount, colorAbsoluteValue)
90
91 diffRecords = calcDiffRecords(oldRecords, newRecords, false)
92
93 // Sort diff records to be more logically grouped for human consumption, even though its JSON.

Callers

nothing calls this directly

Calls 10

EncodeMethod · 0.95
loadRecordsFunction · 0.85
calcDiffRecordsFunction · 0.85
calcMinMaxFunction · 0.85
printTop15MinMaxFunction · 0.85
KeysMethod · 0.80
NewWriterMethod · 0.80
CreateMethod · 0.65
CloseMethod · 0.65
FlushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…