I would like to create an application using Golang to load test a server app I have running. There are some preceeding activities to sending the request or else I would use something like ab etc. I am calling something similar to the below in X number of goroutines.
func sendRequest() *time.Duration {
xmlBody := "SomeXmlHere"
start := time.Now()
resp, err := http.Post("www.example.com", "text/xml", strings.NewReader(xmlBody))
requestTime := time.Since(start)
defer resp.Body.Close()
response, _ := ioutil.ReadAll(resp.Body)
return &requestTime
}
When the request is initiated, the runtime will switch to another goroutine while the request is ongoing. So my question is, will the response times be skewed if another goroutine is long running and blocks the call to time.Since()
? Is there a way around this problem to obtain accurate response times?