forked from pen-lang/pen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.sh
executable file
·81 lines (59 loc) · 1.08 KB
/
benchmark.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
set -e
. $(dirname $0)/utilities.sh
print_directory() {
echo '>>>' "$@"
}
pen_packages() {
for package_file in $(git ls-files | grep pen.json); do
(
directory=$(dirname $package_file)
print_directory $directory
cd $directory
"$@"
)
done
}
rust_crates() {
for cargo_file in $(git ls-files | grep Cargo.toml); do
(
directory=$(dirname $cargo_file)
print_directory $directory
cd $directory
"$@"
)
done
}
benchmark() {
hyperfine -w 3 "$@"
}
benchmark_rust() {
command=$(basename $(pwd) | tr _ -)
(
cd $(cargo metadata --format-version 1 | jq -r .target_directory)/release
benchmark ./$command
)
}
build() {
pen_packages pen build
rust_crates cargo build --release
}
run() {
pen_packages benchmark ./app
rust_crates benchmark_rust
}
while getopts b option; do
case $option in
b)
build=true
;;
esac
done
shift $(expr $OPTIND - 1)
prepare_integration_test $(dirname $PWD/$0)/..
cargo install hyperfine
cd $(dirname $0)/../benchmark
build
if [ -z "$build" ]; then
run
fi