;dev: add performance tests, logging to perf.log, run by just perftest

This commit is contained in:
Simon Michael 2025-11-20 00:01:53 -10:00
parent 64b97b2658
commit 4d0550f1b4
2 changed files with 23 additions and 1 deletions

View File

@ -482,13 +482,23 @@ SHELLTEST := STACK + ' exec -- shelltest --execdir --exclude=/_ --threads=32'
# --hide-successes
# build hledger warning-free and run functional tests, with any shelltest OPTS (requires mktestaddons)
# build hledger warning-free and run functional tests, with any shelltest OPTS. (after mktestaddons)
@functest *STOPTS:
$STACK build --ghc-options=-Werror hledger
time (({{ SHELLTEST }} --hide {{ if STOPTS == '' { '' } else { STOPTS } }} \
hledger/test/ bin/ \
-x hledger/test/perf.test \
-x ledger-compat/ledger-baseline -x ledger-compat/ledger-regress -x ledger-compat/ledger-extra \
&& echo $@ PASSED) || (echo $@ FAILED; false))
# too fragile
# echo
# just perftest {{ STOPTS }}
# run performance tests with the hledger in PATH, logging to perf.log and expecting a certain txns/s. Accepts shelltest OPTS.
@perftest *STOPTS:
echo "Running performance tests..."
time (({{ SHELLTEST }} --hide {{ if STOPTS == '' { '' } else { STOPTS } }} hledger/test/perf.test \
&& echo $@ PASSED) || (echo $@ FAILED; false))
ADDONEXTS := 'pl py rb sh hs lhs rkt exe com bat'
ADDONSDIR := 'hledger/test/cli/addons'

12
hledger/test/perf.test Normal file
View File

@ -0,0 +1,12 @@
# * performance tests
# This file is run after the other functional tests have completed,
# so that they don't slow it down.
# ** 1. Log performance stats to a persistent perf.log.
# so that we can detect changes over time.
# Ideally we would detect regressions and fail automatically,
# but it's hard to ensure consistent machine performance.
$ hledger stats -1 -f ../../examples/10ktxns-1kaccts.journal >>../../perf.log
# ** 2. Test that it hits at least 14k txns/s within a few runs.
$ hledger stats -1 -f ../../examples/10ktxns-1kaccts.journal >>../../perf.log; hledger stats -1 -f ../../examples/10ktxns-1kaccts.journal >>../../perf.log; hledger stats -1 -f ../../examples/10ktxns-1kaccts.journal >>../../perf.log; tail -3 ../../perf.log | grep -qE '[1-9][4-9]... txns/s'