Skip to content

Commit

Permalink
Assorted tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Nov 5, 2023
1 parent 5dbd32e commit a0154ae
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down
14 changes: 13 additions & 1 deletion src/Test/Tasty/Bench/Fit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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'} =
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tasty-bench-fit.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ license-file: LICENSE
maintainer: [email protected]
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
Expand Down Expand Up @@ -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

Expand All @@ -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,
Expand Down

0 comments on commit a0154ae

Please sign in to comment.