#!/bin/bash set -euo pipefail # check how fast copyparty is able to hash files during indexing # assuming an infinitely fast HDD to read from (alternatively, # checks whether you will be bottlenecked by CPU or HDD) # # uses copyparty's default config of using, well, it's complicated: # * if you have more than 8 cores, then 5 threads, # * if you have between 4 and 8, then 4 threads, # * anything less and it takes your number of cores # # can be adjusted with --hash-mt (but alpine caps out at 5) [ $# -ge 1 ] || { echo 'need arg 1: path to copyparty-sfx.py' echo ' (remaining args will be passed on to copyparty,' echo ' for example to tweak the hasher settings)' exit 1 } sfx="$1" shift sfx="$(realpath "$sfx" || readlink -e "$sfx" || echo "$sfx")" awk=$(which gawk || which awk) # try to use /dev/shm to avoid hitting filesystems at all, # otherwise fallback to mktemp which probably uses /tmp td=/dev/shm/cppbenchtmp mkdir $td || td=$(mktemp -d) trap "rm -rf $td" INT TERM EXIT cd $td echo creating 256 MiB testfile in $td head -c $((1024*1024*256)) /dev/urandom > 1 echo creating 127 symlinks to it for n in $(seq 2 128); do ln -s 1 $n; done echo warming up cache cat 1 >/dev/null echo ok lets go python3 "$sfx" -p39204 -e2dsa --dbd=yolo --exit=idx -lo=t "$@" echo and the results are... $awk '/1 volumes in / {printf "%s MiB/s\n", 256*128/$(NF-1)}'