From a0154ae7f1cd1982f5ef455c5416111aa6055d62 Mon Sep 17 00:00:00 2001 From: Bodigrim Date: Sun, 5 Nov 2023 23:19:17 +0000 Subject: [PATCH] Assorted tweaks --- .github/workflows/haskell-ci.yml | 33 +++++++++++++++++++------------- src/Test/Tasty/Bench/Fit.hs | 14 +++++++++++++- tasty-bench-fit.cabal | 12 ++++++------ 3 files changed, 39 insertions(+), 20 deletions(-) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 9c20271..7c78871 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -8,9 +8,9 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.16 +# version: 0.17.20231010 # -# REGENDATA ("0.16",["github","tasty-bench-fit.cabal"]) +# REGENDATA ("0.17.20231010",["github","tasty-bench-fit.cabal"]) # name: Haskell-CI on: @@ -28,19 +28,24 @@ jobs: strategy: matrix: include: - - compiler: ghc-9.6.1 + - compiler: ghc-9.8.1 compilerKind: ghc - compilerVersion: 9.6.1 + compilerVersion: 9.8.1 setup-method: ghcup allow-failure: false - - compiler: ghc-9.4.4 + - compiler: ghc-9.6.3 compilerKind: ghc - compilerVersion: 9.4.4 + compilerVersion: 9.6.3 setup-method: ghcup allow-failure: false - - compiler: ghc-9.2.7 + - compiler: ghc-9.4.7 compilerKind: ghc - compilerVersion: 9.2.7 + compilerVersion: 9.4.7 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.2.8 + compilerKind: ghc + compilerVersion: 9.2.8 setup-method: ghcup allow-failure: false - compiler: ghc-9.0.2 @@ -76,7 +81,7 @@ jobs: apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 if [ "${{ matrix.setup-method }}" = ghcup ]; then mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup" + curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup" chmod a+x "$HOME/.ghcup/bin/ghcup" "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) @@ -85,7 +90,7 @@ jobs: apt-get update apt-get install -y "$HCNAME" mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup" + curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup" chmod a+x "$HOME/.ghcup/bin/ghcup" "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) fi @@ -101,10 +106,12 @@ jobs: echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" HCDIR=/opt/$HCKIND/$HCVER if [ "${{ matrix.setup-method }}" = ghcup ]; then - HC=$HOME/.ghcup/bin/$HCKIND-$HCVER + HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") + HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') + HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') echo "HC=$HC" >> "$GITHUB_ENV" - echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV" - echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV" + echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" + echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV" else HC=$HCDIR/bin/$HCKIND diff --git a/src/Test/Tasty/Bench/Fit.hs b/src/Test/Tasty/Bench/Fit.hs index 2372025..e628a74 100644 --- a/src/Test/Tasty/Bench/Fit.hs +++ b/src/Test/Tasty/Bench/Fit.hs @@ -111,6 +111,11 @@ mkFitConfig f (low, high) = -- Consider running such measurements with @-O0@ or in @ghci@ prompt. This is how -- the usage example above was generated. Without optimizations your program -- allocates much more and triggers GC regularly, somewhat evening out its effect. +-- +-- While suitable for automatic estimates, 'fit' generally provides bad user +-- experience in interactive environments, because it can take a very long time +-- before it returns a result without any heartbeat in between. Consider using +-- 'fits' or enabling @debug@ flag. fit :: FitConfig -> IO Complexity fit cnf = converge <$> fits cnf @@ -122,7 +127,7 @@ converge xs = case zs of ys = NE.toList xs zs = dropWhile (\(x, y, z) -> p x z || p y z) $ - zip3 ys (tail ys) (drop 2 ys) + zip3 ys (drop 1 ys) (drop 2 ys) p Complexity {cmplVarPower = varPow, cmplLogPower = logPow, cmplMultiplier = mult} Complexity {cmplVarPower = varPow', cmplLogPower = logPow', cmplMultiplier = mult'} = @@ -135,6 +140,13 @@ converge xs = case zs of -- -- If 'fit' takes too long, you might wish to implement your own criterion -- of convergence atop of 'fits' directly. +-- +-- >>> cmpls <- fits $ mkFitConfig (\x -> sum [1..x]) (10, 10000) +-- >>> traverse print cmpls +-- 3.36e-8 * x ^ 0.903 +-- 1.39e-8 * x +-- 1.38e-8 * x +-- ... fits :: FitConfig -> IO (NonEmpty Complexity) fits FitConfig {..} = unsafeInterleaveIO $ do lowTime <- measure fitLow diff --git a/tasty-bench-fit.cabal b/tasty-bench-fit.cabal index 669da8f..ee01305 100644 --- a/tasty-bench-fit.cabal +++ b/tasty-bench-fit.cabal @@ -6,8 +6,8 @@ license-file: LICENSE maintainer: andrew.lelechenko@gmail.com author: Bodigrim tested-with: - ghc ==9.6.1 ghc ==9.4.4 ghc ==9.2.7 ghc ==9.0.2 ghc ==8.10.7 - ghc ==8.8.4 ghc ==8.6.5 ghc ==8.4.4 + ghc ==9.8.1 ghc ==9.6.3 ghc ==9.4.7 ghc ==9.2.8 ghc ==9.0.2 + ghc ==8.10.7 ghc ==8.8.4 ghc ==8.6.5 ghc ==8.4.4 homepage: https://github.com/Bodigrim/tasty-bench-fit synopsis: Determine time complexity of a given function @@ -38,10 +38,10 @@ library ghc-options: -Wall build-depends: base >=4.11 && <5, - containers >=0.5.11 && <0.7, - deepseq >=1.4 && <1.5, + containers >=0.5.11 && <0.8, + deepseq >=1.4 && <1.6, infinite-list >=0.1 && <0.2, - tasty >=1.4 && <1.5, + tasty >=1.4 && <1.6, tasty-bench >=0.3.4 && <0.4, regression-simple >=0.2.1 && <0.3 @@ -55,7 +55,7 @@ test-suite tasty-bench-fit-test default-language: Haskell2010 build-depends: base, - containers <0.7, + containers, tasty, tasty-bench, tasty-bench-fit,