MCPcopy
hub / github.com/grpc/grpc-go / formatBenchmark

Function formatBenchmark

benchmark/benchresult/main.go:116–144  ·  view source on GitHub ↗
(fileName string)

Source from the content-addressed store, hash-verified

114}
115
116func formatBenchmark(fileName string) {
117 f, err := os.Open(fileName)
118 if err != nil {
119 log.Fatalf("Read file %s error: %s\n", fileName, err)
120 }
121 defer f.Close()
122 var results []stats.BenchResults
123 decoder := gob.NewDecoder(f)
124 if err = decoder.Decode(&results); err != nil {
125 log.Fatalf("Decode file %s error: %s\n", fileName, err)
126 }
127 if len(results) == 0 {
128 log.Fatalf("No benchmark results in file %s\n", fileName)
129 }
130
131 fmt.Println("\nShared features:\n" + strings.Repeat("-", 20))
132 fmt.Print(results[0].Features.SharedFeatures(results[0].SharedFeatures))
133 fmt.Println(strings.Repeat("-", 35))
134
135 wantFeatures := results[0].SharedFeatures
136 for i := 0; i < len(results[0].SharedFeatures); i++ {
137 wantFeatures[i] = !wantFeatures[i]
138 }
139
140 printHeader()
141 for _, r := range results {
142 printline(r.RunMode+r.Features.PrintableName(wantFeatures), r.Data)
143 }
144}
145
146func main() {
147 if len(os.Args) == 2 {

Callers 1

mainFunction · 0.85

Calls 10

DecodeMethod · 0.95
printHeaderFunction · 0.85
printlineFunction · 0.85
OpenMethod · 0.80
PrintlnMethod · 0.80
SharedFeaturesMethod · 0.80
PrintableNameMethod · 0.80
FatalfMethod · 0.65
CloseMethod · 0.65
PrintMethod · 0.65

Tested by

no test coverage detected