Files
sdb/test/testgrep.sh
Riccardo Schirone 109c102f54 Create pkg-config file in meson and make tests runnable from meson (#158)
* install missing headers
* make tests runnable even if sdb is not installed
* refactor CFLAGS/LDFLAGS/SDB env var settings
* sdb-test.mk: do not use -static because it doesn't work on OS X
* test: use sdb-test.sh in suite/run.sh too
* sdb-test.sh: fix current path detection
2018-10-04 11:59:32 +02:00

50 lines
986 B
Bash
Executable File

#!/bin/sh
# proof that grep is faster than sdb
. ./sdb-test.sh
PATH="../src:$PATH"
printf "\033[33m[+] Creating test database... \033[0m"
sh add10k.sh > /dev/null 2>&1
echo "DONE"
# creates test.db and 'a'
G=6561
T=a.sdb
D=test.db
K=key29988
echo
printf "\033[33m[+] System grep \033[0m"
echo "$ grep 6561 $T"
LINES=`grep $G $T |wc -l`
echo "\033[32mLines: ${LINES}\033[0m"
echo
printf "\033[33m[+] Dump and grep \033[0m"
echo "$ sdb $D | grep $G"
LINES=`${SDB} $D | grep $G | wc -l`
echo "\033[32mLines: ${LINES}\033[0m"
echo
printf "\033[33m[+] Internal grep \033[0m"
echo "$ sdb -g $G $D"
LINES=`${SDB} -g $G $D | wc -l`
echo "\033[32mLines: ${LINES}\033[0m"
#########################
echo
printf "\033[33m[+] Grep get \033[0m"
echo '$ grep "^$K=" $T'
LINES="`grep "^$K=" $T |wc -l `"
echo "\033[32mLines: ${LINES}\033[0m"
echo
printf "\033[33m[+] Sdb get \033[0m"
echo "$ sdb $D $K"
LINES=`${SDB} $D $K | grep -v '^$' | wc -l`
echo "\033[32mLines: ${LINES}\033[0m"