Latency calculation

Hi STephane,

I am using the latest Gatling release ie, snapshot release. I have two httpprotocols for a single simulation. one will be receiving the request from the other httpprotocol. I want to measure latency ie, time when request was sent to httpprotocol1 and time when request reached httpprotocol2. And I have used below lines:

val httpProtocol = http.baseURL(“http://xx.xx.xx.xx”).acceptHeader(“application/xml”)

.extraInfoExtractor((name,status:Status, session:Session, request:Request, response: Response) => {

List(t1=response.lastByteReceived

)

})

val httpProt = http.baseURL(“http://yy.yy.yy.yy”).acceptHeader(“application/xml”)

.extraInfoExtractor((name,status:Status, session:Session, request:Request, response: Response) => {

List(if(request.getUrl().contains(“GetNotifications”)){t2=response.lastByteReceived},

println("T1 : "+t1),

println("T2 : "+t2),

if(t1!=0){

logger.info(“Latency,{}”,t2-t1)

}

)

})

Could you validate this? Because at times, am not receiving proper times. I hope response.lastByteReceived will give the time when last byte of response was received by the server.

Hi,

I’m not sure I get it right. Do you mean that you have 2 populations: one that sends events, and one that gets notified and you want to measure the time the second one gets notified?

If so, you probably cannot be sure that events don’t interleave, (req1, req1, req2, req2) instead of (req1, req2, req1, req2)?
Then, how do you define t1 and t2? Those are global variables, so you have to use @volatile or AtomicLong in order to make changes visible to all threads.

Cheers,

Stéphane