performance-testinggatlingscala-gatling

Gatling data feeder with an increment value


I'm looking to create a data feeder which increments an integer from 1 alongside some other values. I have found a way to achieve this using AtomicInteger. Following code shows how I have implemented it. Is there any other way that I can achieve this for instance using the Iterator.from(0).map() approach.

  def getUUID = randomUUID().toString
  val ordinal = new AtomicInteger(1)

  val itemAttemptForPost = Iterator.continually {
    Map(
      "usedId" -> getUUID ,
      "ordinal" -> ordinal.getAndIncrement()
    )
  }

Solution

  • Note: using from(1) for consistency with your new AtomicInteger(1).

    Iterator.from(1).map { i =>
          Map(
          "usedId" -> randomUUID().toString,
          "ordinal" -> i
        )
    }