Files
spring-boot-demo/excel-export/scripts/run-all.sh
T

51 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Regenerates every file in output/. Takes 15-25 minutes on a shared 2-vCPU box, mostly the XSSF runs.
# Needs JDK 25, Maven, curl, awk, unzip. LibreOffice is optional (step 10 is skipped without it).
set -euo pipefail
cd "$(dirname "$0")/.."
source scripts/measure.sh
mkdir -p output
HOST="$(java -version 2>&1 | grep -v JAVA_TOOL | head -1) | $(nproc) vCPU | $(awk '/MemTotal/ {printf "%d MB RAM", $2/1024}' /proc/meminfo)"
if [ -z "${SKIP_BUILD:-}" ]; then
mvn -q -B test # writes output/01..04 (structure, temp files, csv, endpoints)
mvn -q -B package -DskipTests
fi
hdr() { { echo "# $1"; echo "# $HOST"; echo "# indicative numbers from a shared sandbox, one run per line; see README"; } > "$2"; }
hdr "XSSF under a fixed 512 MB heap: rows until it dies" output/05-xssf-sweep.txt
for n in ${XSSF_ROWS:-10000 25000 50000 100000}; do
measure XSSF "/export/xssf?rows=$n" 512m >> output/05-xssf-sweep.txt
done
hdr "SXSSF under the same 512 MB heap, same rows, plus 1,000,000" output/06-sxssf-sweep.txt
for n in ${XSSF_ROWS:-10000 25000 50000 100000} 1000000; do
measure SXSSF "/export/sxssf?rows=$n" 512m >> output/06-sxssf-sweep.txt
done
hdr "1,000,000 rows: SXSSF and CSV under a 64 MB heap, XSSF given a large heap" output/07-million-rows.txt
measure SXSSF "/export/sxssf?rows=1000000" 64m >> output/07-million-rows.txt
measure CSV "/export/csv?rows=1000000" 64m >> output/07-million-rows.txt
measure XSSF "/export/xssf?rows=1000000" "${XSSF_BIG_HEAP:-3g}" >> output/07-million-rows.txt
hdr "Sheet rolling: 1,100,000 rows, SXSSF, 64 MB heap, default sheet limit 1,048,576" output/08-sheet-rolling.txt
measure SXSSF "/export/sxssf?rows=1100000" 64m /tmp/excel-export-big.xlsx >> output/08-sheet-rolling.txt
{
echo "file size: $(du -m /tmp/excel-export-big.xlsx | cut -f1) MB"
unzip -p /tmp/excel-export-big.xlsx xl/workbook.xml | grep -oE '<sheet [^>]*name="[^"]*"' | sed 's/ r:id.*//'
for s in 1 2; do
echo "sheet$s.xml: $(unzip -p /tmp/excel-export-big.xlsx xl/worksheets/sheet$s.xml | grep -o '<row ' | wc -l) rows (header included)"
done
} >> output/08-sheet-rolling.txt
rm -f /tmp/excel-export-big.xlsx
hdr "compressTempFiles on a 1,000,000-row SXSSF export, 64 MB heap" output/09-compress-temp.txt
measure SXSSF "/export/sxssf?rows=1000000&compress=false" 64m >> output/09-compress-temp.txt
measure SXSSF "/export/sxssf?rows=1000000&compress=true" 64m >> output/09-compress-temp.txt
if command -v soffice >/dev/null; then
bash scripts/libreoffice-check.sh > output/10-libreoffice.txt 2>&1 || true
fi
echo "done"