MCPcopy
hub / github.com/cortexlabs/cortex / runConstantRequestsPerSecond

Function runConstantRequestsPerSecond

dev/load.go:108–135  ·  view source on GitHub ↗
(url string, jsonBytes []byte)

Source from the content-addressed store, hash-verified

106}
107
108func runConstantRequestsPerSecond(url string, jsonBytes []byte) {
109 inFlightCount := Counter{}
110 ticker := time.NewTicker(_requestInterval)
111 done := make(chan bool)
112
113 c := make(chan os.Signal, 1)
114 signal.Notify(c, os.Interrupt, syscall.SIGTERM)
115 go func() {
116 <-c
117 done <- true
118 }()
119
120 start := time.Now()
121
122FOR_LOOP:
123 for {
124 select {
125 case <-done:
126 break FOR_LOOP
127 case <-ticker.C:
128 go runConstantRequestsPerSecondIteration(url, jsonBytes, &inFlightCount, done)
129 }
130 }
131
132 elapsed := time.Since(start)
133 requestRate := float64(_requestCount.Load()) / elapsed.Seconds()
134 fmt.Printf("\nelapsed time: %s | %d requests @ %f req/s | %d succeeded | %d http errors | %d go errors\n", elapsed, _requestCount.Load(), requestRate, _successCount.Load(), _httpErrCount.Load(), _goErrCount.Load())
135}
136
137func runConstantRequestsPerSecondIteration(url string, jsonBytes []byte, inFlightCount *Counter, done chan bool) {
138 if _maxInFlight > 0 {

Callers 1

mainFunction · 0.85

Tested by

no test coverage detected