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

Function main

benchmark/server/main.go:55–97  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

53)
54
55func main() {
56 flag.Parse()
57 if *testName == "" {
58 logger.Fatal("-test_name not set")
59 }
60 lis, err := net.Listen("tcp", ":"+*port)
61 if err != nil {
62 logger.Fatalf("Failed to listen: %v", err)
63 }
64 defer lis.Close()
65
66 cf, err := os.Create("/tmp/" + *testName + ".cpu")
67 if err != nil {
68 logger.Fatalf("Failed to create file: %v", err)
69 }
70 defer cf.Close()
71 pprof.StartCPUProfile(cf)
72 cpuBeg := syscall.GetCPUTime()
73 // Launch server in a separate goroutine.
74 stop := benchmark.StartServer(benchmark.ServerInfo{Type: "protobuf", Listener: lis},
75 grpc.WriteBufferSize(128*1024),
76 grpc.ReadBufferSize(128*1024),
77 )
78 // Wait on OS terminate signal.
79 ch := make(chan os.Signal, 1)
80 signal.Notify(ch, os.Interrupt)
81 <-ch
82 cpu := time.Duration(syscall.GetCPUTime() - cpuBeg)
83 stop()
84 pprof.StopCPUProfile()
85 mf, err := os.Create("/tmp/" + *testName + ".mem")
86 if err != nil {
87 logger.Fatalf("Failed to create file: %v", err)
88 }
89 defer mf.Close()
90 runtime.GC() // materialize all statistics
91 if err := pprof.WriteHeapProfile(mf); err != nil {
92 logger.Fatalf("Failed to write memory profile: %v", err)
93 }
94 fmt.Println("Server CPU utilization:", cpu)
95 fmt.Println("Server CPU profile:", cf.Name())
96 fmt.Println("Server Mem Profile:", mf.Name())
97}

Callers

nothing calls this directly

Calls 10

GetCPUTimeFunction · 0.92
StartServerFunction · 0.92
WriteBufferSizeFunction · 0.92
ReadBufferSizeFunction · 0.92
PrintlnMethod · 0.80
ParseMethod · 0.65
FatalMethod · 0.65
FatalfMethod · 0.65
CloseMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected