Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion benchmark/cljs/benchmark_runner.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

(def println print)

(set! *print-fn* js/print)
(set! *print-fn*
(if (exists? js/print)
js/print
js/console.log))

(simple-benchmark [x 1] (identity x) 1000000)

Expand Down Expand Up @@ -172,6 +175,16 @@
(simple-benchmark [coll (array-map :foo :bar)] (assoc coll :baz :woz) 1000000)
(simple-benchmark [coll (array-map :foo :bar :baz :woz)] (-lookup coll :baz) 1000000)
(simple-benchmark [coll (array-map :foo :bar :baz :woz :lol :rofl)] (-lookup coll :lol) 1000000)
(simple-benchmark
[coll (array-map :foo 1 :bar 2 :baz 3 :woz 4 :lol 5 :rofl 6 :oflr 7 :flro 8
:foo1 9 :bar1 10 :baz1 11 :woz1 12 :lol1 13 :rofl1 14 :oflr1 15 :flro1 16
:foo2 17 :bar2 18 :baz2 19 :woz2 20 :lol2 21 :rofl2 22 :oflr2 23 :flro2 24)]
(-lookup coll :flro2) 1000000)
(simple-benchmark
[coll (array-map "foo" 1 "bar" 2 "baz" 3 "woz" 4 "lol" 5 "rofl" 6 "oflr" 7 "flro" 8
"foo1" 9 "bar1" 10 "baz1" 11 "woz1" 12 "lol1" 13 "rofl1" 14 "oflr1" 15 "flro1" 16
"foo2" 17 "bar2" 18 "baz2" 19 "woz2" 20 "lol2" 21 "rofl2" 22 "oflr2" 23 "flro2" 24)]
(-lookup coll :flro2) 1000000)
(println)

(println ";;; array-map w/ symbols")
Expand Down
2 changes: 2 additions & 0 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
:extra-deps {org.clojure/spec.alpha {:mvn/version "0.5.238"}}}
:compiler.test.run {:main-opts ["-i" "src/test/clojure/cljs/test_runner.clj"
"-e" "(cljs.test-runner/-main)"]}
:benchmark.build {:extra-paths ["benchmark"]
:main-opts ["-m" "cljs.main" "-co" "resources/benchmark.edn" "-c"]}
:runtime.test.build {:extra-paths ["src/test/cljs"]
:main-opts ["-m" "cljs.main" "-co" "resources/test.edn" "-c"]}
:lite.test.build {:extra-paths ["src/test/cljs"]
Expand Down
12 changes: 12 additions & 0 deletions resources/benchmark.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{;:optimizations :advanced
:optimizations :simple
:static-fns true
:optimize-constants true
:pretty-print true
:main cljs.benchmark-runner
:browser-repl false
:output-wrapper true
:compiler-stats true
:verbose true
:output-dir "builds/out-simp-bench"
:output-to "builds/out-simp-bench/core-simp-benchmark.js"}
18 changes: 9 additions & 9 deletions script/benchmark
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
#!/bin/sh

rm -rf builds/out-adv-bench
mkdir -p builds/out-adv-bench
rm -rf builds/out-simp-bench
mkdir -p builds/out-simp-bench

bin/cljsc benchmark "{:optimizations :advanced :output-wrapper true :compiler-stats true :verbose true :output-dir \"builds/out-adv-bench\"}" > builds/out-adv-bench/core-advanced-benchmark.js
clojure -M:benchmark.build

if [ "$V8_HOME" = "" ]; then
echo "V8_HOME not set, skipping V8 benchmarks"
else
echo "Benchmarking with V8"
"${V8_HOME}/d8" builds/out-adv-bench/core-advanced-benchmark.js
"${V8_HOME}/d8" builds/out-simp-bench/core-simp-benchmark.js
fi

if [ "$SPIDERMONKEY_HOME" = "" ]; then
echo "SPIDERMONKEY_HOME not set, skipping SpiderMonkey benchmarks"
else
echo "Benchmarking with SpiderMonkey"
"${SPIDERMONKEY_HOME}/js" -f builds/out-adv-bench/core-advanced-benchmark.js
"${SPIDERMONKEY_HOME}/js" -f builds/out-simp-bench/core-simp-benchmark.js
fi

if ! hash jsc 2>/dev/null; then
echo "jsc not on path, skipping JavaScriptCore benchmarks"
else
echo "Benchmarking with JavaScriptCore"
jsc -f builds/out-adv-bench/core-advanced-benchmark.js
jsc -f builds/out-simp-bench/core-simp-benchmark.js
fi

if [ "$NASHORN_HOME" = "" ]; then
echo "NASHORN_HOME not set, skipping Nashorn benchmarks"
else
echo "Benchmarking with Nashorn"
"${NASHORN_HOME}/jjs" builds/out-adv-bench/core-advanced-benchmark.js
"${NASHORN_HOME}/jjs" builds/out-simp-bench/core-simp-benchmark.js
fi

if [ "$CHAKRACORE_HOME" = "" ]; then
echo "CHAKRACORE_HOME not set, skipping ChakraCore benchmarks"
else
echo "Benchmarking with ChakraCore"
"${CHAKRACORE_HOME}/ch" builds/out-adv-bench/core-advanced-benchmark.js
"${CHAKRACORE_HOME}/ch" builds/out-simp-bench/core-simp-benchmark.js
fi

if [ "$GRAALVM_HOME" = "" ]; then
echo "GRAALVM_HOME not set, skipping GraalVM benchmarks"
else
echo "Benchmarking with GraalVM"
"${GRAALVM_HOME}/js" builds/out-adv-bench/core-advanced-benchmark.js
"${GRAALVM_HOME}/js" builds/out-simp-bench/core-simp-benchmark.js
fi
Loading