git clone https://github.com/clojure/clojurescript
cd clojurescript
script/bootstrap
script/test
Ctrl-C
when it logs
Applying optimizations :advanced to 344 sources
cd builds/out-adv
Download the Closure Compiler standalone JAR from https://dl.google.com/closure-compiler/compiler-latest.zip, unzip it, and copy closure-compiler-v20180716.jar
to the current directory.
Now compile the JavaScript associated with cljs.core
with :advanced
time java -jar closure-compiler-v20180716.jar --js goog/base.js --js goog/object/object.js --js goog/array/array.js --js goog/math/math.js --js goog/math/integer.js --js goog/math/long.js --js goog/string/string.js --js goog/string/stringbuffer.js --js goog/uri/uri.js --js goog/uri/utils.js --js goog/asserts/asserts.js --js goog/debug/error.js --js goog/reflect/reflect.js --js goog/structs/structs.js --js goog/structs/map.js --js goog/functions/functions.js --js goog/iter/iter.js --js goog/dom/nodetype.js --js cljs/core.js -O ADVANCED -D COMPILED=true -W QUIET --jscomp_warning '*' --js_output_file core-compiled-java.js
Now install the Graal native image of the Closure Compiler
npm install -g google-closure-compiler
Compile with the Graal version:
time npx google-closure-compiler --js goog/base.js --js goog/object/object.js --js goog/array/array.js --js goog/math/math.js --js goog/math/integer.js --js goog/math/long.js --js goog/string/string.js --js goog/string/stringbuffer.js --js goog/uri/uri.js --js goog/uri/utils.js --js goog/asserts/asserts.js --js goog/debug/error.js --js goog/reflect/reflect.js --js goog/structs/structs.js --js goog/structs/map.js --js goog/functions/functions.js --js goog/iter/iter.js --js goog/dom/nodetype.js --js cljs/core.js -O ADVANCED -D COMPILED=true -W QUIET --jscomp_warning '*' --js_output_file core-compiled-graal.js
Make sure they both produced the same output:
diff core-compiled-java.js core-compiled-graal.js
On one machine I get 8.840s for the Java version and 5.204s for the Graal native image version. (Speedup: 1.7)
On another I get 15.717s for the Java version and 8.759s for the Graal native image version. (Speedup: 1.8)