mirror of
https://github.com/ebrandi/FDD-book.git
synced 2026-12-06 08:33:30 +00:00
Organize companion code and materials by book part: part-01/ Foundations part-02/ Kernel & driver fundamentals part-03/ Character & block devices part-04/ Networking & storage part-05/ Buses & advanced topics part-06/ Debugging & performance part-07/ Real-world drivers appendices/ Supplementary material README.md Overview and build instructions
37 lines
896 B
Bash
Executable file
37 lines
896 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# measure.sh - Sweep transfer sizes and record rough throughput.
|
|
#
|
|
# Outputs CSV lines of the form:
|
|
# <op>,<bs>,<count>,<rate_Bps>
|
|
#
|
|
# Requires /dev/myblk0 to exist and not be mounted.
|
|
|
|
set -eu
|
|
|
|
DEVICE=${DEVICE:-/dev/myblk0}
|
|
TOTAL=${TOTAL:-$((32 * 1024 * 1024))}
|
|
|
|
if [ ! -c "${DEVICE}" ]; then
|
|
echo "${DEVICE} not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "op,bs,count,duration_s,bytes"
|
|
|
|
for bs in 512 4096 16384 65536 262144 1048576; do
|
|
count=$((TOTAL / bs))
|
|
start=$(date +%s.%N)
|
|
dd if=/dev/zero of="${DEVICE}" bs=${bs} count=${count} \
|
|
conv=fsync 2>/dev/null
|
|
end=$(date +%s.%N)
|
|
duration=$(echo "${end} - ${start}" | bc)
|
|
echo "WRITE,${bs},${count},${duration},${TOTAL}"
|
|
|
|
start=$(date +%s.%N)
|
|
dd if="${DEVICE}" of=/dev/null bs=${bs} count=${count} \
|
|
2>/dev/null
|
|
end=$(date +%s.%N)
|
|
duration=$(echo "${end} - ${start}" | bc)
|
|
echo "READ,${bs},${count},${duration},${TOTAL}"
|
|
done
|