From 0cbcf0b4ab87c7a705a6bdc44ba258b2065c8bf2 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Sun, 4 Jul 2021 19:00:01 +0530 Subject: [PATCH] Factor out targets.sh to be used in test.sh as well --- bin/bench-config.sh | 114 +++--------------------------------------- bin/targets.sh | 117 ++++++++++++++++++++++++++++++++++++++++++++ bin/test.sh | 12 +++-- streamly.cabal | 1 + 4 files changed, 131 insertions(+), 113 deletions(-) create mode 100644 bin/targets.sh diff --git a/bin/bench-config.sh b/bin/bench-config.sh index cd1dc4753..9ee1b9a48 100644 --- a/bin/bench-config.sh +++ b/bin/bench-config.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +BENCH_CONFIG_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)" +source $BENCH_CONFIG_DIR/targets.sh \ + || { echo "Cannot source $BENCH_CONFIG_DIR/targets.sh"; exit 1; } + # Customization options bench_config () { BENCH_REPORT_DIR=benchmark/bench-report @@ -11,117 +15,11 @@ bench_config () { } #------------------------------------------------------------------------------ -# test and benchmark groups +# benchmark groups #------------------------------------------------------------------------------ -# IMPORTANT NOTE: the names "_grp" and "_cmp" suffixes are special, do -# not rename them to something else. - bench_targets () { - base_stream_grp="\ - `bench_only Data.Stream.StreamD` \ - `bench_only Data.Stream.StreamK` \ - `bench_only Data.Stream.StreamDK`" - - prelude_serial_grp="\ - Prelude.Serial \ - Prelude.WSerial \ - Prelude.ZipSerial" - - prelude_concurrent_grp="\ - Prelude.Async \ - Prelude.WAsync \ - Prelude.Ahead \ - Prelude.Parallel \ - Prelude.ZipAsync" - - prelude_other_grp="\ - `test_only Prelude` \ - $(test_only $(dev_build Prelude.Rate)) \ - `bench_only Prelude.Rate` \ - `test_only Prelude.Fold` \ - `test_only Prelude.Concurrent` \ - $(bench_only $(dev_build Prelude.Concurrent)) \ - `bench_only Prelude.Adaptive`" - - array_grp="\ - Data.Array \ - Data.Array.Foreign \ - Data.Array.Prim \ - Data.SmallArray \ - Data.Array.Prim.Pinned" - - base_parser_grp="\ - Data.Parser.ParserD \ - `bench_only Data.Parser.ParserK`" - - parser_grp="\ - Data.Fold \ - Data.Parser" - - list_grp="\ - `test_only Data.List.Base` \ - `test_only Data.List`" - - #------------------------------------------------------------------------------ - # Streaming vs non-streaming - #------------------------------------------------------------------------------ - # The "o-1-space" groups of these benchmarks are run with long stream - # sizes when --long option is used. - - infinite_grp="\ - $prelude_serial_grp \ - $prelude_concurrent_grp \ - `bench_only Prelude.Rate`" - - #------------------------------------------------------------------------------ - # Benchmark comparison groups - #------------------------------------------------------------------------------ - - # *_cmp denotes a comparison benchmark, the benchmarks provided in *_cmp - # variables are compared with each other - base_stream_cmp="Data.Stream.StreamD Data.Stream.StreamK" - serial_wserial_cmp="Prelude.Serial Prelude.WSerial" - serial_async_cmp="Prelude.Serial Prelude.Async" - concurrent_cmp="Prelude.Async Prelude.WAsync Prelude.Ahead Prelude.Parallel" - array_cmp="Memory.Array Data.Array.Prim Data.Array Data.Array.Prim.Pinned" - pinned_array_cmp="Memory.Array Data.Array.Prim.Pinned" - base_parser_cmp=$base_parser_grp - - COMPARISONS="\ - base_stream_cmp \ - serial_wserial_cmp \ - serial_async_cmp \ - concurrent_cmp \ - array_cmp \ - pinned_array_cmp \ - base_parser_cmp" - - #------------------------------------------------------------------------------ - # All test/benchmark modules must be in at least one of these - #------------------------------------------------------------------------------ - - # All groups - GROUP_TARGETS="\ - base_stream_grp \ - prelude_serial_grp \ - prelude_concurrent_grp \ - prelude_other_grp \ - array_grp \ - base_parser_grp \ - parser_grp \ - list_grp \ - infinite_grp" - - # Not in any groups - INDIVIDUAL_TARGETS="\ - Data.Unfold \ - Unicode.Stream \ - FileSystem.Handle \ - `test_only FileSystem.Event` \ - `test_only Network.Socket` \ - `test_only Network.Inet.TCP` \ - `test_only version-bounds`" + targets } #------------------------------------------------------------------------------ diff --git a/bin/targets.sh b/bin/targets.sh new file mode 100644 index 000000000..133c2d912 --- /dev/null +++ b/bin/targets.sh @@ -0,0 +1,117 @@ +#------------------------------------------------------------------------------ +# test and benchmark groups +#------------------------------------------------------------------------------ + +# Depends on RUNNING_TESTS, RUNNING_BENCHMARKS, RUNNING_DEVBUILD variables +# being set for dev_build, test_only, bench_only functions to work. So the +# "targets" fucntion should be called only after these are set. + +# IMPORTANT NOTE: the names "_grp" and "_cmp" suffixes are special, do +# not rename them to something else. + +targets () { + base_stream_grp="\ + `bench_only Data.Stream.StreamD` \ + `bench_only Data.Stream.StreamK` \ + `bench_only Data.Stream.StreamDK`" + + prelude_serial_grp="\ + Prelude.Serial \ + Prelude.WSerial \ + Prelude.ZipSerial" + + prelude_concurrent_grp="\ + Prelude.Async \ + Prelude.WAsync \ + Prelude.Ahead \ + Prelude.Parallel \ + Prelude.ZipAsync" + + prelude_other_grp="\ + `test_only Prelude` \ + $(test_only $(dev_build Prelude.Rate)) \ + `bench_only Prelude.Rate` \ + `test_only Prelude.Fold` \ + `test_only Prelude.Concurrent` \ + $(bench_only $(dev_build Prelude.Concurrent)) \ + `bench_only Prelude.Adaptive`" + + array_grp="\ + Data.Array \ + Data.Array.Foreign \ + Data.Array.Prim \ + Data.SmallArray \ + Data.Array.Prim.Pinned" + + base_parser_grp="\ + Data.Parser.ParserD \ + `bench_only Data.Parser.ParserK`" + + parser_grp="\ + Data.Fold \ + Data.Parser" + + list_grp="\ + `test_only Data.List.Base` \ + `test_only Data.List`" + + #------------------------------------------------------------------------------ + # Streaming vs non-streaming + #------------------------------------------------------------------------------ + # The "o-1-space" groups of these benchmarks are run with long stream + # sizes when --long option is used. + + infinite_grp="\ + $prelude_serial_grp \ + $prelude_concurrent_grp \ + `bench_only Prelude.Rate`" + + #------------------------------------------------------------------------------ + # Benchmark comparison groups + #------------------------------------------------------------------------------ + + # *_cmp denotes a comparison benchmark, the benchmarks provided in *_cmp + # variables are compared with each other + base_stream_cmp="Data.Stream.StreamD Data.Stream.StreamK" + serial_wserial_cmp="Prelude.Serial Prelude.WSerial" + serial_async_cmp="Prelude.Serial Prelude.Async" + concurrent_cmp="Prelude.Async Prelude.WAsync Prelude.Ahead Prelude.Parallel" + array_cmp="Memory.Array Data.Array.Prim Data.Array Data.Array.Prim.Pinned" + pinned_array_cmp="Memory.Array Data.Array.Prim.Pinned" + base_parser_cmp=$base_parser_grp + + COMPARISONS="\ + base_stream_cmp \ + serial_wserial_cmp \ + serial_async_cmp \ + concurrent_cmp \ + array_cmp \ + pinned_array_cmp \ + base_parser_cmp" + + #------------------------------------------------------------------------------ + # All test/benchmark modules must be in at least one of these + #------------------------------------------------------------------------------ + + # All groups + GROUP_TARGETS="\ + base_stream_grp \ + prelude_serial_grp \ + prelude_concurrent_grp \ + prelude_other_grp \ + array_grp \ + base_parser_grp \ + parser_grp \ + list_grp \ + infinite_grp" + + # Not in any groups + INDIVIDUAL_TARGETS="\ + Data.Unfold \ + Unicode.Stream \ + FileSystem.Handle \ + `test_only FileSystem.Event` \ + `test_only Network.Socket` \ + `test_only Network.Inet.TCP` \ + `test_only version-bounds`" +} diff --git a/bin/test.sh b/bin/test.sh index d11be5be5..7c870ff21 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -1,13 +1,15 @@ #!/usr/bin/env bash +SCRIPT_DIR=$(dirname $0) + STREAMLY_VERSION=0.8.0 +BENCH_REPORT_DIR=benchmark/bench-report +source $SCRIPT_DIR/targets.sh #------------------------------------------------------------------------------ # Script #------------------------------------------------------------------------------ -SCRIPT_DIR=$(dirname $0) - print_help () { echo "Usage: $0 " echo " [--targets <"target1 target2 ..." | help>]" @@ -39,7 +41,7 @@ print_help () { #----------------------------------------------------------------------------- RUNNING_TESTS=y -source $SCRIPT_DIR/build-lib.sh +source $BENCH_REPORT_DIR/bin/build-lib.sh USE_GIT_CABAL=1 set_common_vars @@ -79,8 +81,8 @@ set_derived_vars # Determine targets #----------------------------------------------------------------------------- -# Requires RUNNING_DEVBUILD var -source $SCRIPT_DIR/targets.sh +# Defined in targets.sh +targets if test "$(has_item "$TARGETS" help)" = "help" then diff --git a/streamly.cabal b/streamly.cabal index f9066dd8a..c0c1afa51 100644 --- a/streamly.cabal +++ b/streamly.cabal @@ -84,6 +84,7 @@ extra-source-files: bin/run-ci.sh bin/mk-hscope.sh bin/mk-tags.sh + bin/targets.sh bin/test.sh configure configure.ac