This repository has been archived by the owner on Nov 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
chronograph.sh
executable file
·87 lines (73 loc) · 1.84 KB
/
chronograph.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
# An operations script that makes working with this repository easier.
# Written by Tiger Sachse.
SAMPLE_DIR="samples"
ANALYZER_NAME="analyzer"
GRAPHER_NAME="grapher.py"
SAMPLES="code/sources
music/pitches
protein/proteins
dna/dna
nlang/english.1024MB
xml/dblp.xml"
# Download sample text files from the Internet.
download_samples() {
mkdir $SAMPLE_DIR
for SAMPLE in $SAMPLES; do
wget http://pizzachili.dcc.uchile.cl/texts/$SAMPLE.gz -P $SAMPLE_DIR
done
gzip -d $SAMPLE_DIR/*
}
# Install the project.
install_project() {
if [[ $EUID -ne 0 ]]; then
echo "This operation must be run as root."
exit 1
fi
# This function needs these packages to build the required divsufsort library.
apt install gzip git cmake make g++-7 python3-matplotlib
# Override any existing compilers and use the g++-7 compiler.
export CC="g++-7;$CC"
export CXX="g++-7;$CXX"
rm -rf build
mkdir build
cd build
# Install this project using cmake.
cmake ..
make
make install
cd ..
rm -rf build
}
# Run the repository driver to test the divsufsort library.
analyze_text() {
compile_analyzer &&
./$ANALYZER_NAME "$@"
rm -rf $ANALYZER_NAME
}
# Compile the analyzer.
compile_analyzer() {
g++-7 -fcilkplus timer/$ANALYZER_NAME.cpp -o $ANALYZER_NAME \
-l cilkrts -l divsufsort -l libprange
}
# Analyze the results using the provided Python script.
graph_data() {
python3 timer/$GRAPHER_NAME $1
}
# Main entry point of this script.
case "$1" in
"--download-samples")
download_samples
;;
"--install")
install_project
;;
"--analyze")
analyze_text "${@:2}"
;;
"--graph")
graph_data $2
;;
"--compile")
compile_analyzer
;;
esac