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

Function processFlags

benchmark/benchmain/main.go:795–881  ·  view source on GitHub ↗

processFlags reads the command line flags and builds benchOpts. Specifying invalid values for certain flags will cause flag.Parse() to fail, and the program to terminate. This *SHOULD* be the only place where the flags are accessed. All other parts of the benchmark code should rely on the returned b

()

Source from the content-addressed store, hash-verified

793// This *SHOULD* be the only place where the flags are accessed. All other
794// parts of the benchmark code should rely on the returned benchOpts.
795func processFlags() *benchOpts {
796 flag.Parse()
797 if flag.NArg() != 0 {
798 log.Fatal("Error: unparsed arguments: ", flag.Args())
799 }
800
801 opts := &benchOpts{
802 rModes: runModesFromWorkloads(*workloads),
803 benchTime: *benchTime,
804 memProfileRate: *memProfileRate,
805 memProfile: *memProfile,
806 cpuProfile: *cpuProfile,
807 networkMode: *networkMode,
808 benchmarkResultFile: *benchmarkResultFile,
809 useBufconn: *useBufconn,
810 enableKeepalive: *enableKeepalive,
811 connections: *connections,
812 features: &featureOpts{
813 enableTrace: setToggleMode(*traceMode),
814 readLatencies: append([]time.Duration(nil), *readLatency...),
815 readKbps: append([]int(nil), *readKbps...),
816 readMTU: append([]int(nil), *readMTU...),
817 maxConcurrentCalls: append([]int(nil), *maxConcurrentCalls...),
818 reqSizeBytes: append([]int(nil), *readReqSizeBytes...),
819 respSizeBytes: append([]int(nil), *readRespSizeBytes...),
820 compModes: setCompressorMode(*compressorMode),
821 enableChannelz: setToggleMode(*channelzOn),
822 enablePreloader: setToggleMode(*preloaderMode),
823 clientReadBufferSize: append([]int(nil), *clientReadBufferSize...),
824 clientWriteBufferSize: append([]int(nil), *clientWriteBufferSize...),
825 serverReadBufferSize: append([]int(nil), *serverReadBufferSize...),
826 serverWriteBufferSize: append([]int(nil), *serverWriteBufferSize...),
827 sleepBetweenRPCs: append([]time.Duration(nil), *sleepBetweenRPCs...),
828 recvBufferPools: setRecvBufferPool(*recvBufferPool),
829 sharedWriteBuffer: setToggleMode(*sharedWriteBuffer),
830 },
831 }
832
833 if len(*reqPayloadCurveFiles) == 0 {
834 if len(opts.features.reqSizeBytes) == 0 {
835 opts.features.reqSizeBytes = defaultReqSizeBytes
836 }
837 } else {
838 if len(opts.features.reqSizeBytes) != 0 {
839 log.Fatalf("you may not specify -reqPayloadCurveFiles and -reqSizeBytes at the same time")
840 }
841 if len(opts.features.enablePreloader) != 0 {
842 log.Fatalf("you may not specify -reqPayloadCurveFiles and -preloader at the same time")
843 }
844 for _, file := range *reqPayloadCurveFiles {
845 pc, err := stats.NewPayloadCurve(file)
846 if err != nil {
847 log.Fatalf("cannot load payload curve file %s: %v", file, err)
848 }
849 opts.features.reqPayloadCurves = append(opts.features.reqPayloadCurves, pc)
850 }
851 opts.features.reqSizeBytes = nil
852 }

Callers 1

mainFunction · 0.85

Calls 8

NewPayloadCurveFunction · 0.92
runModesFromWorkloadsFunction · 0.85
setToggleModeFunction · 0.85
setCompressorModeFunction · 0.85
setRecvBufferPoolFunction · 0.85
ParseMethod · 0.65
FatalMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected