-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.sh
executable file
·133 lines (122 loc) · 3.33 KB
/
test.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash --login
duration () {
# Nanoseconds only work in GNU date
local starttime=$1
local endtime="$(date +%s%N)"
# required visible decimal place for seconds (leading zeros if needed)
local tests_time="$(printf "%010d" "$(( ${endtime/%N/000000000} - ${starttime/%N/000000000} ))")" # in ns
echo "${tests_time:0:${#tests_time}-9}.${tests_time:${#tests_time}-9:3}"
}
echo "Interpreter | Laufzeit in s"
echo "--- | ---:"
# Python 2
ver="$(/usr/bin/env python --version 2>&1)"
if [[ $ver == "Python 2"* ]] ; then
cd python
starttime="$(date +%s%N)" # nanoseconds_since_epoch
/usr/bin/env python satzgenerator.py 1000000 >/dev/null 2>&1
echo $ver "|" $(duration $starttime)
cd ..
else
echo "Python 2 not installed"
fi
# Python 3
ver="$(/usr/bin/env python3 --version 2>&1)"
if [[ $ver == "Python 3"* ]] ; then
cd python
starttime="$(date +%s%N)"
/usr/bin/env python3 satzgenerator.py 1000000 >/dev/null 2>&1
echo $ver "|" $(duration $starttime)
cd ..
else
echo "Python 3 not installed"
fi
# PyPy
ver="$(/usr/bin/env pypy --version 2>&1)"
if [[ $ver == "Python"* ]] ; then
cd python
ver="$(/usr/bin/env pypy --version 2>&1 | grep PyPy | cut -f2 -d' ')"
starttime="$(date +%s%N)"
/usr/bin/env pypy satzgenerator.py 1000000 >/dev/null 2>&1
echo "PyPy $ver |" $(duration $starttime)
cd ..
else
echo "PyPy not installed"
fi
# Ruby
ver="$(/usr/bin/env ruby --version 2>&1)"
if [[ $ver == "ruby "* ]] ; then
cd ruby
ver="$(/usr/bin/env ruby --version 2>&1 | cut -f2 -d' ')"
starttime="$(date +%s%N)"
/usr/bin/env ruby satzgenerator.rb 1000000 >/dev/null 2>&1
echo "Ruby $ver |" $(duration $starttime)
cd ..
else
echo "Ruby not installed"
fi
# JRuby
if [[ $TRAVIS == "true" ]]; then
# workaround for https://github.com/travis-ci/travis-ci/issues/5477
export JRUBY_OPTS='--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -Xcext.enabled=false -J-Xss2m -Xcompile.invokedynamic=false'
rvm install jruby >/dev/null 2>&1
rvm use jruby >/dev/null
jruby="ruby"
else
jruby="/usr/bin/env jruby"
fi
ver="$($jruby --version 2>&1 | cut -f1-3 -d' ')"
if [[ $ver == "jruby"* ]] ; then
cd ruby
starttime="$(date +%s%N)"
$jruby satzgenerator.rb 1000000 >/dev/null 2>&1
echo "$ver |" $(duration $starttime)
cd ..
else
echo "JRuby not installed"
fi
# Perl
ver="$(/usr/bin/env perl --version 2>&1 | grep "This is perl" | perl -pe 's/[^(]*\(([^)]*)\)[^(]*/$1\n/g')"
if [[ $ver == "v"* ]] ; then
cd perl
starttime="$(date +%s%N)"
/usr/bin/env perl satzgenerator.pl 1000000 >/dev/null 2>&1
echo "Perl $ver |" $(duration $starttime)
cd ..
else
echo "Perl not installed"
fi
# Genie
ver="$(valac --version 2>&1)"
if [[ $ver == "Vala "* ]] ; then
cd genie
starttime="$(date +%s%N)"
./satzgenerator 1000000 >/dev/null 2>&1
echo "Genie ($ver) |" $(duration $starttime)
cd ..
else
echo "valac not installed"
fi
# Java
ver="$(java -version 2>&1)"
if [[ $ver == "java "* ]] ; then
cd java
ver="$(java -version 2>&1 | grep version | cut -d '"' -f2)"
starttime="$(date +%s%N)"
java Satzgenerator 1000000 >/dev/null 2>&1
echo "Java $ver |" $(duration $starttime)
cd ..
else
echo "Java not installed"
fi
# Crystal
ver="$(crystal --version 2>&1 | cut -f1 -d[ | cut -f1 -d'(')"
if [[ $ver == "Crystal "* ]] ; then
cd crystal
starttime="$(date +%s%N)"
./Satzgenerator 1000000 >/dev/null 2>&1
echo "$ver|" $(duration $starttime)
cd ..
else
echo "crystal not installed"
fi