-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvim_benchmark.sh
More file actions
executable file
·113 lines (92 loc) · 2.4 KB
/
Copy pathvim_benchmark.sh
File metadata and controls
executable file
·113 lines (92 loc) · 2.4 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#
# Check the loading time of the various vundle scripts
#
# Defaults
# Location of vimrc
VIMRC="$HOME/.vimrc"
# Location of the vim file
VIM=/Applications/MacVim.app/Contents/MacOS/Vim
# Number of runs
NO_RUN=10
########### ########### ########### ###########
########### ########### ########### ###########
SLEEP_SEC=0.5
function show_help {
echo "$0: -f -c"
}
while getopts "h?v:r:n:" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
v) VIM=$OPTARG
;;
r) VIMRC=$OPTARG
;;
n) NO_RUN=$OPTARG
;;
esac
done
echo "Using vimrc: $VIMRC"
echo "Using vim: $VIM"
# Count the "header" portion
# This is the part up to the first Bundle
HEADER_LINE=$(cat $VIMRC | grep -n 'Bundle' |cut -d: -f 1 | head -n 1)
#echo "Header line is ", $HEADER_LINE
# Separate vim file
head -n $(($HEADER_LINE)) $VIMRC > vimrc_top
grep -v '^Bundle' $VIMRC | tail -n +$(($HEADER_LINE+1)) > vimrc_bottom
grep '^Bundle' $VIMRC | grep -v 'gmarik/vundle' > vimrc_bundles
grep '^Bundle' $VIMRC | grep 'NO_BENCHMARK' > vimrc_nobm_bundles
# Read the bundles into array
IFS=$'\r\n' BUNDLES=($(cat vimrc_bundles))
BUNDLE_NO=${#BUNDLES[@]}
#
# Launch empty for cold-start
#
$VIM -u NONE +:q
$VIM +:q
#
# No bundles (just the rest of the vimrc)
#
TOT=0 # running sum in nanoseconds
for t in $(seq $NO_RUN); do
cat vimrc_top > vimrc_testing
cat vimrc_nobm_bundles >> vimrc_testing
cat vimrc_bottom >> vimrc_testing
sleep $SLEEP_SEC
S=$(date +%s.%N)
$VIM -u vimrc_testing +:q
E=$(date +%s.%N)
TOT=$(echo "$TOT + ($E - $S)" | bc -l)
done
NTIME=$(echo "($TOT / $NO_RUN)" | bc -l)
#echo -e "NONE:\t\t\t$NTIME ms"
printf "%-30.30s: %10f ms\n" NONE $(echo "$NTIME * 1000" | bc -l)
#
# Bundles
#
for n in $(seq 0 $(($BUNDLE_NO-1)) );
do
B=${BUNDLES[n]}
#echo $B
cat vimrc_top > vimrc_testing
cat vimrc_nobm_bundles >> vimrc_testing
echo $B >> vimrc_testing
cat vimrc_bottom >> vimrc_testing
BNAME=$(echo $B | sed "s/.*'\(.*\)'.*$/\1/")
TOT=0 # running sum in nanoseconds
for t in $(seq $NO_RUN); do
sleep $SLEEP_SEC
S=$(date +%s.%N)
$VIM -u vimrc_testing +:q
E=$(date +%s.%N)
TOT=$(echo "$TOT + ($E - $S)" | bc -l)
done
BTIME=$(echo "(($TOT / $NO_RUN)- $NTIME) *1000" | bc -l)
#echo -e "$BNAME:\t\t\t$BTIME ms"
printf "%-30.30s: %10f ms\n" $BNAME $BTIME
done
# clean-up
rm -f vimrc_bundles vimrc_testing vimrc_top vimrc_nobm_bundles vimrc_bottom