How to define pause

Hi to all,

I’m new to Gatling and a pure noob in Scala.

I’ve this code :

def apply = {

val extUsers = Integer.getInteger(“users”, 1)

val extRampup = Integer.getInteger(“rampup”, 0)

val extPause = Long.getLong(“pause”, 1L)

val chain_0 = chain

.exec(

http(“request_1”)

.get(extWebapp + “/libs-release/com/me/parent/parent/3/parent-3.pom”)

.headers(headers_1)

)

.exec(

http(“request_2”)

.get(extWebapp + “/libs-release/com/me/parent/parent/3/parent-3.pom.sha1”)

.headers(headers_1)

)

.pause(extPause, MILLISECONDS)

.exec(

http(“request_3”)

.get(extWebapp + “/libs-release/com/me//web/1.0.0-12/web-1.0.0-12.pom”)

.headers(headers_1)

)

.pause(extPause, MILLISECONDS)

pause require Long but I wonder how to get Long from parms ?

Error was :

Collecting simulations...
Exception in thread "main" java.lang.RuntimeException: Compilation failed:
simulations/com/me/Clean.scala:13: error: value getLong is not a member of object Long
               val extPause  = Long.getLong("pause", 1L)
                                    ^
simulations/com/me/Clean.scala:13: error: value getLong is not a member of object Long
        val extPause  = Long.getLong("pause", 1L)

Thanks for your help :slight_smile:

val extPause = System.getProperty(“pause”).toLong if you want to be able to pass a number > Integer.MAX_VALUE

or val extPause = Integer.getInteger(“pause”, 1).toLong if you want a default value

Cheers,

Stéphane

2012/9/4 Henri Gomez <henri.gomez@gmail.com>

Actually, I wonder if Duration might be Integers instead of Longs.

2012/9/4 Stéphane Landelle <slandelle@excilys.com>

val extPause = System.getProperty("pause").toLong if you want to be able to
pass a number > Integer.MAX_VALUE

or val extPause = Integer.getInteger("pause", 1).toLong if you want a
default value

Thanks, I used this.

Now, I should refactor generated .scala, got class too large error at
compile time ;-/

Really? Wow

What’s your stacktrace? You can maybe edit the JVM options so it can compile.

2012/9/4 Henri Gomez <henri.gomez@gmail.com>

Really? Wow

What's your stacktrace? You can maybe edit the JVM options so it can
compile.

I collected a maven build with about 1250 HTTP requests :slight_smile:

Ouch!

Well, you could probably refactor your Simulation (for example, build file and sha1 requests together), but I’m not sure it would help from a maintenance standpoint.

You can probably tweak some JVM options so Gatling can compile your Simualtion.
What’s your stacktrace exactly?

2012/9/4 Henri Gomez <henri.gomez@gmail.com>

Ouch!

Well, you could probably refactor your Simulation (for example, build file
and sha1 requests together), but I'm not sure it would help from a
maintenance standpoint.

You can probably tweak some JVM options so Gatling can compile your
Simualtion.
What's your stacktrace exactly?

I didn't keep it but it was a message about Class of 96kb tool large error

I wasn’t aware of this kind of limit.
Feel free to send it to me so I can have a look.

2012/9/5 Henri Gomez <henri.gomez@gmail.com>

I wasn't aware of this kind of limit.
Feel free to send it to me so I can have a look.

64k max :slight_smile:

OK,

So you can do something very simple: move all your chains definitions out of the method.

You have something like:

class MySimulation extends Simulation {

def apply = {
val chain1 = …
val chain2 = …

val scn = scenario("foo)
.insertChain(chain1)
.insertChain(chain2)

List(scn…)
}
}

Transform it into:

class MySimulation extends Simulation {

lazy val chain1 = …
lazy val chain2 = …

def apply = {
val scn = scenario("foo)
.insertChain(chain1)
.insertChain(chain2)

List(scn…)
}
}

and you should be fine

2012/9/5 Henri Gomez <henri.gomez@gmail.com>

Tremendous.

That's what I call a strong and reactive support.

Thanks Stéphane !

You’re welcome.

That was a funny one, I’ll add it to the FAQ.

2012/9/5 Henri Gomez <henri.gomez@gmail.com>