adding basic benchmarking stuff

This commit is contained in:
Jorge Morante 2019-01-02 10:33:32 +01:00
parent 66b0571170
commit 71507f53e8
6 changed files with 119 additions and 0 deletions

View File

@ -144,6 +144,8 @@ function run_fingers_copy_command() {
fi
}
# %BENCHMARK_END%
while read -rsn1 char; do
# Escape sequence, flush input
if [[ "$char" == $'\x1b' ]]; then

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
# %BENCHMARK_START%
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $CURRENT_DIR/utils.sh

50
test/benchmark.sh Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env bash
target=$1
benchmark_repo_path="/tmp/tmux-fingers-benchmark"
function setup_window_size() {
stty cols 174
stty rows 42
}
function snippet_for {
echo "echo \"\$(cat /tmp/benchmark-execution-id) $1 \$((\$(date +%s%N)/1000000))\" >> ~/shared/benchmark.log"
}
function setup_benchmark_repo() {
echo "Setting up benchmark repo ..."
rm -rf "$benchmark_repo_path"
cp -r ~/shared "$benchmark_repo_path"
pushd "$benchmark_repo_path" &> /dev/null
find . -type f | xargs sed -i "s!# %BENCHMARK_START%!$(snippet_for "start")!"
find . -type f | xargs sed -i "s!# %BENCHMARK_END%!$(snippet_for "end")!"
popd &> /dev/null
}
function set_execution_id() {
execution_id="$(mktemp -u "benchmark.XXXXXX")"
echo "$execution_id" > /tmp/benchmark-execution-id
}
if [[ "$target" == "within-vm" ]]; then
setup_window_size
setup_benchmark_repo
set_execution_id
pushd "$benchmark_repo_path" &> /dev/null
for benchmark in $(ls $benchmark_repo_path/test/benchmarks/*.sh); do
for i in {1..50}; do
echo "* Running $benchmark [ $i ]"
sleep 1
$benchmark
done
done
popd &> /dev/null
elif [[ -z "$target" ]]; then
echo "Running benchmarks"
vagrant up "$target" &>> /dev/null
vagrant ssh "$target" -c "cd shared && ./test/benchmark.sh within-vm" 2> /dev/null
fi

View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
#set -x
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $CURRENT_DIR/../tmuxomatic.sh
source $CURRENT_DIR/../helpers.sh
tmuxomatic__begin begin_hook
begin_with_conf "benchmark"
init_pane
tmuxomatic__exec "cat ./test/fixtures/grep-output"
invoke_fingers
tmuxomatic send-keys "C-c"
tmuxomatic__end end_hook

5
test/conf/benchmark.conf Normal file
View File

@ -0,0 +1,5 @@
set -g prefix C-a
set -g @fingers-compact-hints '0'
set -g default-terminal 'screen-256color'
run /tmp/tmux-fingers-benchmark/tmux-fingers.tmux

42
test/fixtures/benchmark vendored Normal file
View File

@ -0,0 +1,42 @@
265982390429758 21362301420008 214882893312190 11554155254778
93112662828415 1861636117514 24293224364897 11616967922589
149561703515620 147192438517408 119362656132653 259473161016622
26182816618282 749425011333 147894782452 6442732125800
3537130105336 141162223621551 91591152616370 171632212717214
297263221030670 31198631515200 2000545606028 145532950528175
18022140422319 177071079827303 110342670114356 185239264440
222352552627429 198841343024320 284501924918415 319402012730857
37673530947 1488750949859 231481731431188 13193123525466
7013796711758 11432920120193 635473127653 3101985454008
68503003211186 28808147557353 5611755517014 7416147411419
3129768624280 267571483317777 851621635652 10455258643735
9061703118615 19579308143142 2148192128021 6173076710102
35102323818615 320662001031610 181373169332438 21549634016318
13298366824787 158073252417041 677227996806 4954163968740
23115783425287 64631276326967 111312908917157 182592183213454
84301535915650 5743953160 18438947914073 29497177372166
22316194161386 132972607318923 147362181313176 10183176899020
4437348216794 6735342623369 13226397113030 2250832389266
66412833810787 181691605229889 18876812529962 1789342018621
912106516920 220161710416067 99612181032344 15138301620065
26851651615927 183051502617127 277012151320289 244882340415011
240402604016713 303082422917199 4209180631952 3249713933226
28137793427901 314413187918194 27778518525320 16978203091898
2419179329323 10115128533863 4448323724928 25533123582200