MCPcopy Index your code
hub / github.com/cortexlabs/cortex / runConstantInFlightIteration

Function runConstantInFlightIteration

dev/load.go:202–244  ·  view source on GitHub ↗
(url string, jsonBytes []byte, loopNum int)

Source from the content-addressed store, hash-verified

200}
201
202func runConstantInFlightIteration(url string, jsonBytes []byte, loopNum int) bool {
203 start := time.Now()
204
205 wasKilled := false
206 killed := make(chan bool)
207 c := make(chan os.Signal, 1)
208 signal.Notify(c, os.Interrupt, syscall.SIGTERM)
209 go func() {
210 <-c
211 killed <- true
212 }()
213
214 doneChans := make([]chan struct{}, _numConcurrent)
215 for i := range doneChans {
216 doneChans[i] = make(chan struct{})
217 }
218
219 for i := range doneChans {
220 doneChan := doneChans[i]
221
222 go func() {
223 makeRequestLoop(url, jsonBytes)
224 doneChan <- struct{}{}
225 }()
226 }
227
228LOOP:
229 for _, doneChan := range doneChans {
230 select {
231 case <-killed:
232 wasKilled = true
233 break LOOP
234 case <-doneChan:
235 continue
236 }
237 }
238
239 elapsed := time.Now().Sub(start)
240 requestRate := float64(_requestCount.Load()) / elapsed.Seconds()
241 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())
242
243 return wasKilled
244}
245
246func makeRequestLoop(url string, jsonBytes []byte) {
247 var i int

Callers 1

runConstantInFlightFunction · 0.85

Calls 2

makeRequestLoopFunction · 0.85
SubMethod · 0.80

Tested by

no test coverage detected