Seperate chart build from benchmarks

Add extra-source-files to streamly.cabal

Fix review comments

Rename Chart.hs to BenchReport.hs

Fix extra-source-files

Remove no-charts flag
This commit is contained in:
Ranjeet Kumar Ranjan 2021-06-11 16:03:06 +05:30 committed by Harendra Kumar
parent 1e9482e6ef
commit 8fd51b2a37
8 changed files with 69 additions and 34 deletions

View File

@ -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.

View File

@ -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

View File

@ -0,0 +1 @@
packages: benchmark/bench-report/bench-report.cabal

View File

@ -0,0 +1,30 @@
{ nixpkgs ? import <nixpkgs> {}, 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

View File

@ -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

View File

@ -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
}

View File

@ -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