[#3] Simplify demo and benchmark

No need to build everything every time and no need to do it in docker.

Signed-off-by: Stanislav Bogatyrev <s.bogatyrev@yadro.com>
This commit is contained in:
Stanislav Bogatyrev 2023-02-10 15:57:35 +03:00 committed by fyrchik
parent a5347ee68e
commit 3a7bdcc020
3 changed files with 39 additions and 38 deletions

35
auto.sh
View file

@ -1,35 +0,0 @@
#!/usr/bin/env bash
B="\033[0;1m"
G="\033[0;92m"
R="\033[0m"
echo -e "${B}${G}Let's make some hash${R}"
echo -e "\n${B}${G} - cleanup environment${R}"
echo -e "remove files: small.hash, large.hash, large.txt"
docker exec -it hash-demo sh -c "rm -rf small.hash"
docker exec -it hash-demo sh -c "rm -rf large.hash"
docker exec -it hash-demo sh -c "rm -rf large.txt"
echo -e "\n${B}${G} - make large file (concat small files)${R}"
for i in $(seq -f "%02g" 10)
do
echo " #> cat $i.txt >> large.txt"
docker exec -it hash-demo sh -c "cat $i.txt >> large.txt"
done
echo -e "\n${B}${G} - make hash of small files${R}"
for i in $(seq -f "%02g" 10)
do
echo -e " #> homo -file $i.txt | tee -a small.hash"
docker exec -it hash-demo sh -c "homo -file $i.txt | tee -a small.hash"
done
echo -e "\n${B}${G} - make hash of large${R}"
echo -e " #> homo -file large.txt | homo -concat"
docker exec -it hash-demo sh -c 'homo -file large.txt | homo -concat'
echo -e "\n${B}${G} - make hash of pieces${R}"
echo -e " #> cat small.hash | homo -concat"
docker exec -it hash-demo sh -c 'cat small.hash | homo -concat '

View file

@ -5,10 +5,8 @@ OUT="${OUT:-$(mktemp /tmp/random-file.XXXXXX)}"
dd if=/dev/urandom of="$OUT" bs="$BLOCK_SIZE" count=1 dd if=/dev/urandom of="$OUT" bs="$BLOCK_SIZE" count=1
go build ./cmd/tzsum || exit 1
for impl in avx avx2 generic; do for impl in avx avx2 generic; do
echo $impl implementation: echo $impl implementation:
time ./tzsum -name "$OUT" -impl $impl time ./bin/tzsum -name "$OUT" -impl $impl
echo echo
done done

38
demo.sh Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
#set -x
BLOCK_SIZE=${1:-100M} # 100Mb by default
TMPDIR="${TMPDIR:-$(mktemp -d)}"
OUT="${OUT:-"${TMPDIR}/bighash"}"
echo "Preparing big file at ${OUT}..."
dd if=/dev/urandom of="$OUT" bs="$BLOCK_SIZE" count=1
echo "Make 4 smaller parts from ${OUT}..."
split -dn 4 "${OUT}" "${TMPDIR}/"
echo -n "Big file hash: "
TZALL=$(./bin/tzsum -impl avx2 -name "${OUT}" | awk '{print $1}')
echo "${TZALL}"
for i in $(seq -f "%02g" 0 3)
do
echo -n "Part ${i} hash: "
PART=$(./bin/tzsum -impl avx2 -name "${TMPDIR}/${i}" | awk '{print $1}')
echo "${PART}" | tee -a "${TMPDIR}/part.hashes"
done
echo -n "Cumulative: "
TZCUM=$(./bin/homo -concat -file "${TMPDIR}/part.hashes")
echo "${TZCUM}"
if [[ "$TZCUM" == "$TZALL" ]]; then
echo "Original and cumulative hashes are equal!"
else
echo "Original and cumulative hashes are NOT equal!"
fi
echo -ne "Cleaning up .. "
rm -rf "${TMPDIR}"
echo "Done!"