(url string, jsonBytes []byte)
| 106 | } |
| 107 | |
| 108 | func 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 | |
| 122 | FOR_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 | |
| 137 | func runConstantRequestsPerSecondIteration(url string, jsonBytes []byte, inFlightCount *Counter, done chan bool) { |
| 138 | if _maxInFlight > 0 { |
no test coverage detected