Fast Clojure Hello World Using GraalVM On Mac
Version
Command
Time (seconds)
Java
time java -jar target/fastclj-1.0-standalone.jar
1.354
GraalVM
time ./fastclj-1.0-standalone
0.014
lein new fastclj; cd fastclj
cat<<'END'>./project.clj
(defproject fastclj "1.0"
:description "Fast hello world using GraalVM"
:dependencies [[org.clojure/clojure "1.9.0"]]
:main fastclj.core
:aot :all)
END
cat<<'END'>./src/fastclj/core.clj
(ns fastclj.core (:gen-class))
(defn -main [& args] (println "Hello world!"))
END
lein compile && lein uberjar
time java -jar target/fastclj-1.0-standalone.jar
wget https://github.com/oracle/graal/releases/download/vm-1.0.0-rc12/graalvm-ce-1.0.0-rc12-macos-amd64.tar.gz
tar zxvf graalvm-ce-1.0.0-rc12-macos-amd64.tar.gz
GRAAL_BIN="$PWD/graalvm-ce-1.0.0-rc12/Contents/Home/bin"
$GRAAL_BIN/native-image \
-H:+ReportUnsupportedElementsAtRuntime \
-J-Xmx3G -J-Xms3G --no-server \
-jar target/fastclj-1.0-standalone.jar
ls -l ./fastclj-1.0-standalone
time ./fastclj-1.0-standalone