Skip to content

armgit / hey

Public Imported from GitHub
0

HTTP load generator, ApacheBench (ab) replacement

Go

added body closing fixing the open files problem added reading of the resp body, allowing Go to reuse resources

Charles Murrayff0773a1e56e
diff --git a/commands/run.go b/commands/run.go
index 53a5b75..6a437d0 100644
--- a/commands/run.go
+++ b/commands/run.go
@@ -15,6 +15,7 @@
package commands
import (
+ "io"
"net/http"
"sync"
"time"
@@ -69,6 +70,9 @@ func (b *Boom) run() {
func (b *Boom) worker(clientChan chan int, wg *sync.WaitGroup) {
defer wg.Done()
+
+ buffer := make([]byte, 1024*1024*2)
+
// Pick one request from channel and process.
for _ = range clientChan {
s := time.Now()
@@ -83,6 +87,12 @@ func (b *Boom) worker(clientChan chan int, wg *sync.WaitGroup) {
duration: time.Now().Sub(s),
err: err,
}
+
+ if resp != nil {
+ io.ReadFull(resp.Body, buffer)
+ resp.Body.Close()
+ }
+
b.bar.Increment()
}
}