BuoyantIO/slow_cooker

latency numbers don't measure reading the body

stevej opened this issue · 0 comments

After talking with oliver, we noticed that throughput was impacted by large responses but that latency reported wasn't.

We should move measurement of elapsed down to after the body is read

    start := time.Now()
    response, err := client.Do(req)

    elapsed := time.Since(start)
    if err != nil {
        received <- &MeasuredResponse{0, 0, 0, false, err}
    } else {
        sz, _ := io.Copy(ioutil.Discard, response.Body)
        response.Body.Close()
        received <- &MeasuredResponse{uint64(sz), response.StatusCode, elapsed.Nanoseconds(), false, nil}
    }