????Gatling????
????Gatling????????Scala??д???????????????????Akka??Netty??????????????:
????· ??????
????· ????HTML????
????· ????????????(recoder)???????????DSL
????Gatling VS Jmeter
????Jmeter??????????????????????????????Э?飬?????????????????????
??????Gatling?????????????????????Scala DSL????xml??????????jmeter????????????????????????
????????Jmeter??Gatling???????????????μ? infoq??????
????????Gatling??? Maven ?? Gradle ??????????????????????????? Jenkins ?У????????CI?????С?
????TIPS: ?????????н???汾??????gatling?????????? maven??? ?? gradle??? ?γ?????maven/gradle?????????????????????????????С??????gatling??????????????????????????
????Gatling????????
??????????? ???? zip?????????????????????????JDK???????ú? JAVA_HOME ?????JAVA?????????????????????
????Gatling??????????????????:
??  LICENSE
??
????bin
??      gatling.bat
??      gatling.sh
??      recorder.bat
??      recorder.sh
??
????conf
??      gatling-akka.conf
??      gatling.conf
??      logback.xml
??      recorder.conf
??
????lib
????results
??      .keep
??
????user-files
????bodies
??      .keep
??
????data
??      search.csv
??
????simulations
????computerdatabase
??  BasicSimulation.scala
??
????advanced
????AdvancedSimulationStep01.scala
????AdvancedSimulationStep02.scala
????AdvancedSimulationStep03.scala
????AdvancedSimulationStep04.scala
????AdvancedSimulationStep05.scala
????bin/ ?????gatling??????????? conf/ ?????????????????????? lib/ ???gatling?????????????????ù?? results/ ?????棬 user-files/ ?????????????????????????????????????????????????
????zip????????????????????????????????? BasicSimulation.scala ?????????Ч?????????? bin/gatling.(bat|sh) ??????????????????????????? ?????? ??????? AdvancedSimulationStep ???Ч????? BasicSimulation ?????£???????????Щ?ο???DSLд???????
?????Щ???е?DSL?ο?????
????????gatling??jmeter??????????????λ???recorder?????????????a??????????????????????н??????????????????????????????????????????????????????дDSL????????????м?????????????????????????????????????????????ο???DSL
????Random?????????
????????????????????????????????????????????????????????????????????????????????????????????? Random ????????Scala?????????????????
scala.util.Random ?????????????????????????á????????????????:
forever(
exec(http("Random id browse")
.get("/articles/" + scala.util.Random.nextInt(100))
.check(status.is(200))
)
??????? scala.util.Random.nextInt(100) ??????е???λ???????????????????涼????????gatling?????????????????DSL???????????????й???????????????Random?????й????????????????????????С????? Feeder ???? Feeder ??gatling??????????????????????????? Feeder ???:
val randomIdFeeder =
Iterator.continually(Map("id" ->
(scala.util.Random.nextInt(100))))
forever(
feed(randomIdFeeder)
.exec(http("Random id browse")
.get("/articles/${id}"))
.check(status.is(200))
)
????feed() ?????????????? Iterator[Map[String?? T]] ?????????????????????????????????
??????? import ??????????
???????????д??? Feeders.scala ??????洢????????????? Feeder :
import scala.util.Random
object LinchangFeeders {
def randomGeoFeeder() : Iterator[Map[String?? Number]] = {
val LNG_RANGE = List(108.75?? 109.1)
val LAT_RANGE = List(34.0?? 34.4)
return Iterator.continually(
Map(
"lng" -> (
Random.nextFloat() * (LNG_RANGE(1)
- LNG_RANGE(0)) + LNG_RANGE(0)
)
??"lat" -> (
Random.nextFloat() * (LAT_RANGE(1)
- LAT_RANGE(0)) + LAT_RANGE(0)
)
)
)
}
def randomOffsetFeeder() : Iterator[Map[String?? Number]] = {
Iterator.continually(Map("offset" -> Random.nextInt(100)))
}
}