Reputation: 71
I'm trying to test socket.io with gatling and i'm using exec block:
//...
.exec(session => {
val socket = IO.socket(socketURL + session.get("token").as[String])
val printListener: Emitter.Listener = new Emitter.Listener {
override def call(args: AnyRef*): Unit = {
println(args) //Stop time here for example
}
}
socket.on("info", printListener)
socket.connect()
socket.emit("info", "{}") //Start timer
session
})
//...
Is any way to have time of execution of exec block in gatling report?
Upvotes: 1
Views: 857
Reputation: 577
I know almost zero about Gatling I read that Session
is a kind of Map
so you might do something like this sessiont.set("startTime", currentTimeMillis)
but it would return another session, bc it is immutable so you would need to do a little more.
If not you might do a workaround something like this:
//...
.exec(session => {
var start:Long = 0L
val socket = IO.socket(socketURL + session.get("token").as[String])
val printListener: Emitter.Listener = new Emitter.Listener {
override def call(args: AnyRef*): Unit = {
println( "Time: "+((System.nanoTime - start) / 1000000) )
println(args) //Stop time here for example
}
}
socket.on("info", printListener)
socket.connect()
socket.emit("info", (()=>{ start = System.nanoTime;"{}"})()) //Start timer
session
})
//...
I didn't test this code.. it is almost a psudo code, it is a bit ugly but I consider it could work. I hope this helps. Cheers.
EDITED!
Upvotes: 1