test: Add by word experiment

main
Sean McBride 4 years ago
parent 8dd53dfd96
commit 4aac097566

@ -0,0 +1,5 @@
*.pnm
*.png
*.csv
*.txt
*.log

@ -0,0 +1,7 @@
# OCR varied by word
Generates pnm image files containing random words from the wamerican dictionary.
The number of words are varied between 1, 10, 100 in order to assess how the size of text OCRed affects the execution profile of the sandbox serving the request.
Run `install.sh` to install required tools and `run.sh` to run the tests.

@ -0,0 +1,19 @@
#!/bin/bash
# Executes the runtime in GDB
# Substitutes the absolute path from the container with a path relatively derived from the location of this script
# This allows debugging outside of the Docker container
# Also disables pagination and stopping on SIGUSR1
experiment_directory=$(pwd)
project_directory=$(cd ../../.. && pwd)
binary_directory=$(cd "$project_directory"/bin && pwd)
export LD_LIBRARY_PATH="$binary_directory:$LD_LIBRARY_PATH"
export PATH="$binary_directory:$PATH"
gdb --eval-command="handle SIGUSR1 nostop" \
--eval-command="handle SIGPIPE nostop" \
--eval-command="set pagination off" \
--eval-command="set substitute-path /sledge/runtime $project_directory" \
--eval-command="run $experiment_directory/spec.json" \
sledgert

@ -0,0 +1,4 @@
#!/bin/bash
# Installs the deps needed for run.sh
sudo apt-get install netpbm pango1.0-tools wamerican

@ -0,0 +1,53 @@
#!/bin/bash
# Executes the runtime in GDB
# Substitutes the absolute path from the container with a path relatively derived from the location of this script
# This allows debugging outside of the Docker container
# Also disables pagination and stopping on SIGUSR1
experiment_directory=$(pwd)
project_directory=$(cd ../../.. && pwd)
binary_directory=$(cd "$project_directory"/bin && pwd)
log="$experiment_directory/log.csv"
if [ "$1" != "-d" ]; then
SLEDGE_SANDBOX_PERF_LOG=$log PATH="$binary_directory:$PATH" LD_LIBRARY_PATH="$binary_directory:$LD_LIBRARY_PATH" sledgert "$experiment_directory/spec.json" >rt.log 2>&1 &
sleep 2
else
echo "Running under gdb"
fi
word_counts=(1 10 100)
declare -A word_count_to_port
word_count_to_port["1_words.pnm"]=10000
word_count_to_port["10_words.pnm"]=10001
word_count_to_port["100_words.pnm"]=10002
total_count=100
for ((i = 0; i < total_count; i++)); do
echo "$i"
for word_count in "${word_counts[@]}"; do
echo "${word_count}"_words.pnm
words="$(shuf -n"$word_count" /usr/share/dict/american-english)"
pango-view --font=mono -qo "$word_count"_words.png -t "$words"
pngtopnm "$word_count"_words.png >"$word_count"_words.pnm
result=$(curl -H 'Expect:' -H "Content-Type: text/plain" --data-binary @"${word_count}"_words.pnm localhost:${word_count_to_port["$word_count"_words.pnm]} 2>/dev/null)
diff -ywBZE --suppress-common-lines <(echo "$words") <(echo "$result")
echo "==============================================="
done
done
if [ "$1" != "-d" ]; then
sleep 2
echo -n "Running Cleanup: "
rm ./*.png ./*.pnm
pkill --signal sigterm sledgert >/dev/null 2>/dev/null
sleep 2
pkill sledgert -9 >/dev/null 2>/dev/null
echo "[DONE]"
fi

@ -0,0 +1,42 @@
{
"active": "yes",
"name": "gocr_1_word",
"path": "gocr_wasm.so",
"port": 10000,
"relative-deadline-us": 50000000000,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 5335057,
"http-resp-headers": [],
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain"
},
{
"active": "yes",
"name": "gocr_10_words",
"path": "gocr_wasm.so",
"port": 10001,
"relative-deadline-us": 50000000000,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 5335057,
"http-resp-headers": [],
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain"
},
{
"active": "yes",
"name": "gocr_100_words",
"path": "gocr_wasm.so",
"port": 10002,
"relative-deadline-us": 50000000000,
"argsize": 1,
"http-req-headers": [],
"http-req-content-type": "text/plain",
"http-req-size": 5335057,
"http-resp-headers": [],
"http-resp-size": 5335057,
"http-resp-content-type": "text/plain"
}
Loading…
Cancel
Save