reset variable at the end of the loop

Hi,

I have a code where the main loop needs to run twice and the counters that have been initialized at the beginning needs to reset to 0. I currently have

I currently have this piece of code inside .repeat(2){} , but it doesnt reset the counter.

var counterX are instance variables outside Gatling’s Session.

When you do session.set(“counterX”, 0) you’re defining/overriding a Session variable with key “counterX” of type Integer/Long/Whatever with value of 0.

Something like this should work.

`

val counter1 = new AtomicLong(0);

val counter1Feeder = Iterator.continually(Map(“counter1” → {
var nextVal: Long = counter1.incrementAndGet()

if (nextVal==2){
counter1 = 0
}
nextVal;
}))

`

Then feed the counter1Feeder to the scenario.