2 # This file is part of NIT ( http://www.nitlanguage.org ).
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # Shell script to bench json parsers over different documents
18 source ..
/bench_common.sh
19 source ..
/bench_plot.sh
21 ## CONFIGURATION OPTIONS ##
23 # Default number of times a command must be run with bench_command
24 # Can be overrided with 'the option -n'
32 nitc
--semi
-global scripts
/csv_gen.nit
-o scripts
/csv_gen
33 echo "Generating 1000 lines documents"
34 .
/scripts
/csv_gen
10 1000 inputs
/1000_l.csv
35 .
/scripts
/csv_gen
10 1000 inputs
/1000_uni_l.csv
--unicode
36 echo "Generating 10000 lines documents"
37 .
/scripts
/csv_gen
10 10000 inputs
/10000_l.csv
38 .
/scripts
/csv_gen
10 10000 inputs
/10000_uni_l.csv
--unicode
39 echo "Generating 100000 lines documents"
40 .
/scripts
/csv_gen
10 100000 inputs
/100000_l.csv
41 .
/scripts
/csv_gen
10 100000 inputs
/100000_uni_l.csv
--unicode
42 echo "Generating 1000000 lines documents"
43 .
/scripts
/csv_gen
10 1000000 inputs
/1000000_l.csv
44 .
/scripts
/csv_gen
10 1000000 inputs
/1000000_uni_l.csv
--unicode
49 echo "run_bench: ./csv_bench.sh [options]"
50 echo " -v: verbose mode"
51 echo " -n count: number of execution for each bar (default: $count)"
57 while [ "$stop" = false
]; do
59 -v
) verbose
=true
; shift;;
60 --fast
) fast
=true
; shift;;
62 -n
) count
="$2"; shift; shift;;
67 if [ -z
"$fast" ]; then
73 echo "Compiling engines"
77 javac
-cp './scripts/commons-csv-1.3.jar' scripts
/JavaCSV.java
81 go build
-o scripts
/go_csv scripts
/go_csv.go
83 echo "Nit/Ad-Hoc Parser"
85 nitc
--semi
-global scripts
/nit_csv.nit
-o scripts
/nit_csv
87 declare -a script_names
=('Python 3 - Pandas' 'Python 2 - Pandas' 'Go' 'Nit' 'Python 3 - Standard' 'Python 2 - Standard' 'Java - Apache commons' 'Ruby')
88 declare -a script_cmds
=('python3 scripts/python_csv.py' 'python2 scripts/python_csv.py' './scripts/go_csv' './scripts/nit_csv' 'python3 scripts/python_stdcsv.py' 'python2 scripts/python_stdcsv.py' "java -cp /usr/share/java/commons-csv.jar:. scripts.JavaCSV" 'ruby scripts/ruby_csv.rb')
90 for script in `seq 1 ${#script_cmds[@]}`; do
91 echo "Preparing res for ${script_names[$script - 1]}"
92 prepare_res
"./out/${script_names[$script - 1]}.dat" "${script_names[$script - 1]}" "${script_names[$script - 1]}"
93 for file in inputs
/*.csv
; do
94 fname
=`basename $file .csv`
95 bench_command
$file "Benching file $file using ${script_cmds[$script - 1]} parser" ${script_cmds[$script - 1]} $file
100 rm scripts
/JavaCSV.class
103 plot out
/bench_csv.gnu