-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathbench.sh
More file actions
executable file
·49 lines (39 loc) · 2.27 KB
/
bench.sh
File metadata and controls
executable file
·49 lines (39 loc) · 2.27 KB
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
#!/bin/bash
# Exit on error of any of the following lines.
set -e
usage() {
echo "Usage:"
echo "\tbench.sh [value of k]"
echo ""
echo "Examples:"
echo "\tbench.sh 2"
}
if [ $# -ne 1 ]
then
usage
exit 1
fi
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
PYTHON_EXEC_NAME="cnot_all_observables"
SCALING_FACTOR="$1"
BENCH_DIRECTORY="${PARENT_PATH}/data/${PYTHON_EXEC_NAME}_k=${SCALING_FACTOR}_$(date '+%F_%H-%M-%S')"
echo "Saving all benchmark data to ${BENCH_DIRECTORY}"
mkdir -p $BENCH_DIRECTORY
echo "Statistical profiling of ${PYTHON_EXEC_NAME}.py using pyinstrument..."
python -m pyinstrument -o "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}_k=${SCALING_FACTOR}.html" -r html ${PYTHON_EXEC_NAME}.py -k "${SCALING_FACTOR}"
echo "Profiling saved as an HTML webpage in ${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}_k=${SCALING_FACTOR}.html"
CLI_OUTDIR="${BENCH_DIRECTORY}/dae2circuits/"
DAE_CNOT_FILE="$(realpath "${PARENT_PATH}/../assets/logical_cnot.dae")"
CLI_CMD="tqec dae2circuits --out-dir ${CLI_OUTDIR} -k ${SCALING_FACTOR} --add-detectors ${DAE_CNOT_FILE}"
echo "Statistical profiling of the command '${CLI_CMD}' using pyinstrument..."
python -m pyinstrument -o "${BENCH_DIRECTORY}/tqec_dae2circuits_k=${SCALING_FACTOR}.html" -r html --from-path ${CLI_CMD}
echo "Profiling saved as an HTML webpage in ${BENCH_DIRECTORY}/tqec_dae2circuits_k=${SCALING_FACTOR}.html"
echo "Results of the tqec dae2circuits command saved in '${CLI_OUTDIR}'."
# echo "Profiling ${PYTHON_EXEC_NAME}.py using cProfile..."
# python -m cProfile -o "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}.pstats" ${PYTHON_EXEC_NAME}.py -k $@
# echo "cProfile information saved in ${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}.pstats"
# echo "Generating graphs from profiling report..."
# python -m flameprof --width 4800 --font-size 10 "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}.pstats" > "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}_flamegraph.svg"
# python -m gprof2dot -n 0 -e 0 --depth 2 -f pstats "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}.pstats" > "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}.dot"
# dot -Tsvg -o "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}_callgraph.svg" < "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}.dot"
# dot -Tpng -o "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}_callgraph.png" < "${BENCH_DIRECTORY}/${PYTHON_EXEC_NAME}.dot"