From 27cdd5385dc89b9eafff96753d82c408766ad626 Mon Sep 17 00:00:00 2001 From: Alexander Yastrebov Date: Fri, 5 Jan 2024 00:41:06 +0100 Subject: [PATCH] wip,test: add rounding test case Added two test cases from the discussion https://github.com/gunnarmorling/1brc/pull/5#discussion_r1440578784 Neither all implementations match baseline nor they match precise value of `33.6+31.7+21.9+14.6=25.5`: ``` $ ./test_all.sh src/test/resources/samples/measurements-rounding-baseline.txt 2>/dev/null | tee /tmp/rounding-baseline.log FAIL armandino FAIL artsiomkorzun PASS baseline PASS bjhara PASS criccomini FAIL ddimtirov FAIL ebarlas FAIL filiphr FAIL itaske PASS jgrateron FAIL khmarbaise FAIL kuduwa-keshavram PASS lawrey PASS moysesb FAIL nstng PASS padreati FAIL palmr PASS richardstartin FAIL royvanrijn PASS seijikun PASS spullara PASS truelive $ ./test_all.sh src/test/resources/samples/measurements-rounding-precise.txt 2>/dev/null | tee /tm p/rounding-precise.log PASS armandino PASS artsiomkorzun FAIL baseline FAIL bjhara FAIL criccomini FAIL ddimtirov PASS ebarlas PASS filiphr FAIL itaske FAIL jgrateron PASS khmarbaise FAIL kuduwa-keshavram FAIL lawrey FAIL moysesb PASS nstng FAIL padreati PASS palmr FAIL richardstartin PASS royvanrijn FAIL seijikun FAIL spullara FAIL truelive $ diff -y /tmp/rounding-baseline.log /tmp/rounding-precise.log FAIL armandino | PASS armandino FAIL artsiomkorzun | PASS artsiomkorzun PASS baseline | FAIL baseline PASS bjhara | FAIL bjhara PASS criccomini | FAIL criccomini FAIL ddimtirov FAIL ddimtirov FAIL ebarlas | PASS ebarlas FAIL filiphr | PASS filiphr FAIL itaske FAIL itaske PASS jgrateron | FAIL jgrateron FAIL khmarbaise | PASS khmarbaise FAIL kuduwa-keshavram FAIL kuduwa-keshavram PASS lawrey | FAIL lawrey PASS moysesb | FAIL moysesb FAIL nstng | PASS nstng PASS padreati | FAIL padreati FAIL palmr | PASS palmr PASS richardstartin | FAIL richardstartin FAIL royvanrijn | PASS royvanrijn PASS seijikun | FAIL seijikun PASS spullara | FAIL spullara PASS truelive | FAIL truelive ``` Its also interesting that e.g. `itaske` produces different results between runs and thus may pass or fail sporadically. For #49 --- src/test/resources/samples/measurements-rounding-baseline.out | 1 + src/test/resources/samples/measurements-rounding-baseline.txt | 4 ++++ src/test/resources/samples/measurements-rounding-precise.out | 1 + src/test/resources/samples/measurements-rounding-precise.txt | 4 ++++ test.sh | 2 +- test_all.sh | 2 +- 6 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/samples/measurements-rounding-baseline.out create mode 100644 src/test/resources/samples/measurements-rounding-baseline.txt create mode 100644 src/test/resources/samples/measurements-rounding-precise.out create mode 100644 src/test/resources/samples/measurements-rounding-precise.txt diff --git a/src/test/resources/samples/measurements-rounding-baseline.out b/src/test/resources/samples/measurements-rounding-baseline.out new file mode 100644 index 000000000..0c6e935d3 --- /dev/null +++ b/src/test/resources/samples/measurements-rounding-baseline.out @@ -0,0 +1 @@ +{Rounding=14.6/25.4/33.6} diff --git a/src/test/resources/samples/measurements-rounding-baseline.txt b/src/test/resources/samples/measurements-rounding-baseline.txt new file mode 100644 index 000000000..f7c18a679 --- /dev/null +++ b/src/test/resources/samples/measurements-rounding-baseline.txt @@ -0,0 +1,4 @@ +Rounding;33.6 +Rounding;31.7 +Rounding;21.9 +Rounding;14.6 diff --git a/src/test/resources/samples/measurements-rounding-precise.out b/src/test/resources/samples/measurements-rounding-precise.out new file mode 100644 index 000000000..0cb7c659f --- /dev/null +++ b/src/test/resources/samples/measurements-rounding-precise.out @@ -0,0 +1 @@ +{Rounding=14.6/25.5/33.6} diff --git a/src/test/resources/samples/measurements-rounding-precise.txt b/src/test/resources/samples/measurements-rounding-precise.txt new file mode 100644 index 000000000..f7c18a679 --- /dev/null +++ b/src/test/resources/samples/measurements-rounding-precise.txt @@ -0,0 +1,4 @@ +Rounding;33.6 +Rounding;31.7 +Rounding;21.9 +Rounding;14.6 diff --git a/test.sh b/test.sh index 4bec03641..8c9f2578d 100755 --- a/test.sh +++ b/test.sh @@ -22,7 +22,7 @@ if [ -z "$1" ]; then exit 1 fi -for sample in $(ls src/test/resources/samples/*.txt); do +for sample in $(ls "$2"); do echo "Validating calculate_average_$1.sh -- $sample" rm -f measurements.txt diff --git a/test_all.sh b/test_all.sh index e1141d7b2..03dead842 100755 --- a/test_all.sh +++ b/test_all.sh @@ -21,7 +21,7 @@ for impl in $(ls calculate_average_*.sh | sort); do noext="${impl%%.sh}" name=${noext##calculate_average_} - if output=$(./test.sh "$name" 2>&1); then + if output=$(./test.sh "$name" "$1" 2>&1); then echo "PASS $name" else echo "FAIL $name"