diff --git a/benchmark/README.md b/benchmark/README.md index 88d5090eb..06254c0a9 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -126,13 +126,13 @@ it basically selects all benchmarks starting with Run a specific benchmark in `Prelude.Serial` suite: ``` -$ bench.sh --benchmarks Prelude.Serial --prefix Prelude.Serial/o-1-space/generation/unfoldr +$ bench.sh --benchmarks Prelude.Serial --prefix Prelude.Serial/o-1-space.generation.unfoldr ``` Run a benchmark directly instead of running it through `bench.sh`: ``` -$ cabal run bench:Prelude.Serial -- Prelude.Serial/o-1-space/generation/unfoldr +$ cabal run bench:Prelude.Serial --prefix Prelude.Serial/o-1-space.generation.unfoldr ``` The options after `--` are the benchmark executable options. diff --git a/benchmark/Chart.hs b/benchmark/bench-report/BenchReport.hs similarity index 100% rename from benchmark/Chart.hs rename to benchmark/bench-report/BenchReport.hs diff --git a/benchmark/bench-report/bench-report.cabal b/benchmark/bench-report/bench-report.cabal new file mode 100644 index 000000000..d2786d3ca --- /dev/null +++ b/benchmark/bench-report/bench-report.cabal @@ -0,0 +1,23 @@ +cabal-version: 2.2 +name: bench-report +version: 0.0.0 +synopsis: Benchmark report generation +description: Benchmark reporting application is not included in the overall + cabal project so that the dependencies of both can remain independent. + Benchmark reporting has a lot of dependencies that usually lag behind + when new GHC releases arrive. + +------------------------------------------------------------------------------- +-- benchmark comparison and presentation +------------------------------------------------------------------------------- + +executable bench-report + default-language: Haskell2010 + ghc-options: -Wall + hs-source-dirs: . + main-is: BenchReport.hs + buildable: True + build-Depends: + base >= 4.9 && < 5 + , bench-show >= 0.3 && < 0.4 + , transformers >= 0.4 && < 0.6 diff --git a/benchmark/bench-report/cabal.project b/benchmark/bench-report/cabal.project new file mode 100644 index 000000000..54dab7f17 --- /dev/null +++ b/benchmark/bench-report/cabal.project @@ -0,0 +1 @@ +packages: benchmark/bench-report/bench-report.cabal diff --git a/benchmark/bench-report/default.nix b/benchmark/bench-report/default.nix new file mode 100644 index 000000000..81f0c56e9 --- /dev/null +++ b/benchmark/bench-report/default.nix @@ -0,0 +1,30 @@ +{ nixpkgs ? import {}, compiler ? "default", doBenchmark ? false }: + +let + + inherit (nixpkgs) pkgs; + + f = { mkDerivation, base, bench-show, stdenv, transformers }: + mkDerivation { + pname = "bench-report"; + version = "0.0.0"; + src = ./.; + isLibrary = false; + isExecutable = true; + executableHaskellDepends = [ base bench-show transformers ]; + description = "Benchmark report generation"; + license = "unknown"; + hydraPlatforms = stdenv.lib.platforms.none; + }; + + haskellPackages = if compiler == "default" + then pkgs.haskellPackages + else pkgs.haskell.packages.${compiler}; + + variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id; + + drv = variant (haskellPackages.callPackage f {}); + +in + + if pkgs.lib.inNixShell then drv.env else drv diff --git a/benchmark/streamly-benchmarks.cabal b/benchmark/streamly-benchmarks.cabal index 505f5f6c5..0f52d9bca 100644 --- a/benchmark/streamly-benchmarks.cabal +++ b/benchmark/streamly-benchmarks.cabal @@ -44,11 +44,6 @@ flag has-llvm manual: True default: False -flag no-charts - description: Disable benchmark charts in development build - manual: True - default: False - flag opt description: off=-O0 (faster builds), on=-O2 manual: True @@ -507,21 +502,3 @@ benchmark Unicode.Stream type: exitcode-stdio-1.0 hs-source-dirs: Streamly/Benchmark/Unicode main-is: Stream.hs - -------------------------------------------------------------------------------- --- benchmark comparison and presentation -------------------------------------------------------------------------------- - -executable chart - default-language: Haskell2010 - ghc-options: -Wall - hs-source-dirs: . - main-is: Chart.hs - if flag(dev) && !flag(no-charts) && !impl(ghcjs) - buildable: True - build-Depends: - base >= 4.9 && < 5 - , bench-show >= 0.3 && < 0.4 - , transformers >= 0.4 && < 0.6 - else - buildable: False diff --git a/bin/bench.sh b/bin/bench.sh index 827564fb6..03ace938f 100755 --- a/bin/bench.sh +++ b/bin/bench.sh @@ -71,11 +71,11 @@ list_comparisons () { # chart is expensive to build and usually not required to be rebuilt, # use master branch as fallback cabal_which_report() { - local path=$(cabal_which streamly-benchmarks x $1) + local path=$(cabal_which bench-report x $1) if test -z "$path" then echo "Cannot find $1 executable, trying in dist-newstyle" 1>&2 - local path1=$(cabal_which_builddir dist-newstyle streamly-benchmarks x $1) + local path1=$(cabal_which_builddir dist-newstyle bench-report x $1) if test -z "$path1" then local path2="./bin/$1" @@ -93,7 +93,7 @@ cabal_which_report() { } find_report_prog() { - local prog_name="chart" + local prog_name="bench-report" hash -r local prog_path=$(cabal_which_report $prog_name) if test -x "$prog_path" @@ -105,16 +105,16 @@ find_report_prog() { } build_report_prog() { - local prog_name="chart" + local prog_name="bench-report" local prog_path=$(cabal_which_report $prog_name) hash -r if test ! -x "$prog_path" -a "$BUILD_ONCE" = "0" then - echo "Building bench-show executables" + echo "Building bench-report executables" BUILD_ONCE=1 - $CABAL_EXECUTABLE v2-build --flags dev chart \ - || die "bench-show build failed" + $CABAL_EXECUTABLE v2-build bench-report --project-file=benchmark/bench-report/cabal.project \ + || die "bench-report build failed" elif test ! -x "$prog_path" then @@ -129,8 +129,8 @@ build_report_progs() { build_report_prog || exit 1 local prog prog=$(find_report_prog) || \ - die "Cannot find bench-show executable" - echo "Using bench-show executable [$prog]" + die "Cannot find bench-report executable" + echo "Using bench-report executable [$prog]" fi } diff --git a/streamly.cabal b/streamly.cabal index 96316e697..5848936d3 100644 --- a/streamly.cabal +++ b/streamly.cabal @@ -60,6 +60,10 @@ extra-source-files: appveyor.yml benchmark/*.hs benchmark/README.md + benchmark/bench-report/BenchReport.hs + benchmark/bench-report/bench-report.cabal + benchmark/bench-report/cabal.project + benchmark/bench-report/default.nix benchmark/Streamly/Benchmark/Data/*.hs benchmark/Streamly/Benchmark/Data/Array/Stream/Foreign.hs benchmark/Streamly/Benchmark/Data/Parser/*.hs