Skip to content

Instantly share code, notes, and snippets.

@olafurpg
Last active April 6, 2020 10:47
Show Gist options
  • Select an option

  • Save olafurpg/0cfa29af87c8a80a82a2281c456213c3 to your computer and use it in GitHub Desktop.

Select an option

Save olafurpg/0cfa29af87c8a80a82a2281c456213c3 to your computer and use it in GitHub Desktop.

Revisions

  1. olafurpg revised this gist Apr 6, 2020. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions Nailgun.sh
    Original file line number Diff line number Diff line change
    @@ -7,11 +7,15 @@ cs launch com.martiansoftware:nailgun-server:0.9.1 org.scala-lang:scala-compiler
    # Step 3: create basic Scala hello world
    echo 'println("Hello world!")' > Main.scala

    # Step 4: evaluate Scala program with nailgun server
    # Step 4: assemble the classpath.
    # You need at least the standard library, but you can add more libraries (for example JSON).
    CLASSPATH=$(cs fetch --classpath org.scala-lang:scala-library:2.13.1)

    # Step 5: evaluate the Scala hello world program with the nailgun server
    for i in {1..1000}; do
    time ng --nailgun-port 2113 scala.tools.nsc.MainGenericRunner -classpath $(cs fetch --classpath org.scala-lang:scala-library:2.13.1) -usejavacp Main.scala
    time ng --nailgun-port 2113 scala.tools.nsc.MainGenericRunner -classpath $CLASSPATH -usejavacp Main.scala
    done

    # Once the nailgun process becomes hot, you should see that compile+run takes ~200ms on every run
    # Once the nailgun process becomes hot, the compile+run feedback loop eventually becomes around ~200ms
    # > Hello world!
    # > real 0m0.199s
  2. olafurpg created this gist Apr 6, 2020.
    17 changes: 17 additions & 0 deletions Nailgun.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Step 1: install coursier and nailgun
    brew install nailgun coursier/formulas/coursier

    # Step 2: start nailgun server with the Scala compiler on the classpath
    cs launch com.martiansoftware:nailgun-server:0.9.1 org.scala-lang:scala-compiler:2.13.1 --main com.martiansoftware.nailgun.NGServer -- 2113 &

    # Step 3: create basic Scala hello world
    echo 'println("Hello world!")' > Main.scala

    # Step 4: evaluate Scala program with nailgun server
    for i in {1..1000}; do
    time ng --nailgun-port 2113 scala.tools.nsc.MainGenericRunner -classpath $(cs fetch --classpath org.scala-lang:scala-library:2.13.1) -usejavacp Main.scala
    done

    # Once the nailgun process becomes hot, you should see that compile+run takes ~200ms on every run
    # > Hello world!
    # > real 0m0.199s