Skip to content

Commit 090bebe

Browse files
committed
fix(benchmarks): Get dart2js'ed benchmarks running on node
1 parent 223f4e0 commit 090bebe

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

run-benchmarks.sh

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
set -e
33

4+
# Prepend text to a file in-place.
5+
function di::prepend_text {
6+
local file=$1
7+
local text=$2
8+
9+
# NOTE: sed -i doesn't work on osx/bsd
10+
tmpfile=$(mktemp -t di_benchmark.XXXXXX)
11+
echo "$text" > $tmpfile
12+
cat "$file" >> $tmpfile
13+
cp -f "$tmpfile" "$file"
14+
rm -f "$tmpfile"
15+
}
16+
417
BENCHMARKS="module_benchmark.dart
518
dynamic_injector_benchmark.dart
619
static_injector_benchmark.dart
@@ -11,21 +24,30 @@ mkdir -p benchmark/generated_files
1124
dart scripts/class_gen.dart
1225

1326
# run tests in dart
14-
for b in $BENCHMARKS
15-
do
16-
dart benchmark/$b
27+
echo "Dart VM Benchmarks:"
28+
echo "-------------------"
29+
for b in $BENCHMARKS; do
30+
echo "Running: $b"
31+
dart benchmark/$b
1732
done
1833

1934
# run dart2js on tests
35+
echo
36+
echo "Compiling with dart2js:"
37+
echo "-----------------------"
2038
mkdir -p out
21-
echo "running dart2js"
22-
for b in $BENCHMARKS
23-
do
24-
dart2js --minify benchmark/$b -o out/$b.js > /dev/null
39+
for b in $BENCHMARKS; do
40+
echo "$b"
41+
dart2js --minify benchmark/$b -o out/$b.js > /dev/null
42+
# HACK node.js doesn't understand self
43+
di::prepend_text "out/$b.js" "var self=this"
2544
done
2645

2746
# run tests in node
28-
for b in $BENCHMARKS
29-
do
30-
node out/$b.js
47+
echo
48+
echo "JS Benchmarks:"
49+
echo "--------------"
50+
for b in $BENCHMARKS; do
51+
echo "Running: $b"
52+
node out/$b.js
3153
done

0 commit comments

Comments
 (0)