Write data into csv file

Hi,

I want to write some session details of the running simulation into csv file so that i use the data from csv file for running another script. Is there anyway in gatling to achieve this?

gatling.io/docs/2.0.0-RC2/http/http_protocol.html#dumping-custom-data

Hello Stephane ,

I need to realize the same but i did not understand in which way the link you sended was an answer .

Could you help ?

Regards

Try this:

`

package loadtest

import com.github.tototoshi.csv._
import io.gatling.core.Predef._

object SaveDataToFile {

createEmptyCSVFile()

implicit object CSVFormat extends DefaultCSVFormat {
override val delimiter = ‘;’
override val lineTerminator = “\n”
}

def createEmptyCSVFile(): Unit = {
val csv = CSVWriter.open(file = “data.csv”, append = false)
csv.writeRow(List(
“timestamp”,
“session_user_id”
))
csv.close()
}

def saveDataToFile() = exec(session => {
val csv = CSVWriter.open(file = “data.csv”, append = true)
csv.writeRow(List(
System.currentTimeMillis / 1000,
session.userId
))
csv.close()

session
})
}

// usage in scenario:
exec(SaveDataToFile())

`

Have fun!

Will it be performance efficient?
For example:
I need to analyze the performance of an API which creates user and once the job is completed, it should clean up all those created users.
So I can use exec (exec(PostAPIForUser)) to call api which will create user and user your way to dump all responses in csv file so that i can use them in after method to read them and delete those created users.

But my query is will exec(SaveDataToFile()) will not affect performance analysis of exec(PostAPIForUser) as it will work in chaining or its impact will be negligible?

Thanks