-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbenchmark.sh
More file actions
executable file
·35 lines (31 loc) · 968 Bytes
/
benchmark.sh
File metadata and controls
executable file
·35 lines (31 loc) · 968 Bytes
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
delim="----------------"
echo "Building blook"
go build
echo $delim
file=large.log
file_from=10000000
file_to=40000000
search_from=17000400
search_to=17000700
expected_res=301
if [ ! -e "$file" ] ; then
echo "File $file doesn't exist. Creating it, please wait"
seq -f %1.f $file_from $file_to > "$file"
echo $delim
fi
echo "Benchmarking. Please, wait: the whole benchmark can take some time"
echo $delim
echo "blook results:"
blook_res=$(time ./blook $search_from $search_to large.log | wc -l)
echo $delim
echo "sed results:"
sed_res=$(time sed -ne '/'$search_from'/,/'$search_to'/ p' large.log | wc -l)
echo $delim
echo "awk results:"
awk_res=$(time awk -v from=$search_from -v to=$search_to '$1>=from && $1<=to' large.log | wc -l)
echo $delim
if [[ $blook_res -eq $expected_res ]] && [[ $sed_res -eq $expected_res ]] && [[ $awk_res -eq $expected_res ]] ; then
echo "Done"
else
echo "Wrong: lines count should be the same for all the commands"
fi