Skip to content

Instantly share code, notes, and snippets.

View nremond's full-sized avatar

Nicolas Rémond nremond

View GitHub Profile
@nremond
nremond / gatling_websocket_demo.scala
Last active May 27, 2019 09:28
Demo of Gatling Websocket API
package basic
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import akka.util.duration._
import bootstrap._
import scala.collection.mutable
// Simulation for the Play20 chat sample app
// cf : (https://github.com/playframework/Play20/tree/master/samples/scala/websocket-chat)
import scala.collection.mutable
case class Node(
value: Option[Char] = None,
leaves: mutable.ArrayBuffer[String] = mutable.ArrayBuffer.empty,
nodes: mutable.ArrayBuffer[Node] = mutable.ArrayBuffer.empty) {
@nremond
nremond / gist:2972382
Created June 22, 2012 12:10
Account feeder
class AccountFeeder() extends com.excilys.ebi.gatling.core.feeder.Feeder {
import org.joda.time.DateTime
import scala.util.Random
private val RNG = new Random()
// random number in between [a...b]
def randInt(a:Int, b:Int) = RNG.nextInt(b-a) + a
def daysOfMonth(year:Int, month:Int) = new DateTime(year, month, 1, 0, 0, 0, 000).dayOfMonth().getMaximumValue()
@nremond
nremond / TestSwitch.java
Created March 31, 2017 12:56
Switch statement with strings
class TestSwitch {
String day;
public TestSwitch(String day) {
this.day = day;
}
class TestSwitch {
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}
Day day;

Keybase proof

I hereby claim:

  • I am nremond on github.
  • I am nremond (https://keybase.io/nremond) on keybase.
  • I have a public key whose fingerprint is F977 A6FE 0378 5224 E90D 48E9 78AB 58AA 3102 58BC

To claim this, I am signing this object:

class NicoBench extends AbstractBenchmark {
val cacheUri = new ConcurrentHashMap[URI, Int]
@Test
@BenchmarkOptions(benchmarkRounds = 20000, warmupRounds = 5000, concurrency = 8)
def uri_hashcode() {
val uri = new URI("http://fake.com/" + ThreadLocalRandom.current.nextInt(0, 1000))
cacheUri.putIfAbsent(uri, 123)
cacheUri.get(uri)
object Nico2 {
import scala.concurrent.duration._
///
implicit class UserNumberImplicit(number: Int) {
def users = new UserNumber(number)
}
class UserNumber(val number: Int)
@nremond
nremond / gist:4699699
Created February 2, 2013 23:20
String interpolation benchmark
import scala.testing.Benchmark
val a="aaa"
val b="bbb"
val c="ccc"
object Format1 extends Benchmark {
def run = String.format("%s - %s - %s\n", a, b, c)
}
@nremond
nremond / gatling-ssl-session-tracking.scala
Last active December 10, 2015 20:08
Gatling simulation that hightlights the problem with Gatling when using SSL session tracking.
package basic
import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import bootstrap._
class BasicExampleSimulation extends Simulation {
val counterFeeder = new Feeder[Int] {
private val gen = Stream.from(1).toIterator