Skip to content

Commit

Permalink
Add guessPolynomialComplexity
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Jul 6, 2024
1 parent b6a1870 commit 96f734c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.1.1

* Introduce `Test.Tasty.Bench.Crossover`.
* Introduce `guessPolynomialComplexity`.

## 0.1

Expand Down
4 changes: 4 additions & 0 deletions src/Test/Tasty/Bench/Fit.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# HLINT ignore "Avoid restricted function" #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}

-- | Guess complexity of the function.
module Test.Tasty.Bench.Fit (
Expand All @@ -14,6 +16,7 @@ module Test.Tasty.Bench.Fit (
Complexity (..),
Measurement (..),
guessComplexity,
guessPolynomialComplexity,
evalComplexity,

-- * Predicates
Expand All @@ -39,6 +42,7 @@ import Test.Tasty.Bench.Fit.Complexity (
Complexity (..),
evalComplexity,
guessComplexity,
guessPolynomialComplexity,
isConstant,
isCubic,
isLinear,
Expand Down
14 changes: 14 additions & 0 deletions src/Test/Tasty/Bench/Fit/Complexity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
module Test.Tasty.Bench.Fit.Complexity (
Complexity (..),
guessComplexity,
guessPolynomialComplexity,
evalComplexity,

-- * Predicates
Expand Down Expand Up @@ -179,6 +180,19 @@ guessComplexity xys =
| otherwise =
[c1, c2]

-- | Same as guessComplexity, but the power of \( \log x \) ('cmplLogPower')
-- is pinned to be 0.
--
-- @since 0.1.1
guessPolynomialComplexity :: Map Word Measurement -> Complexity
guessPolynomialComplexity xys =
trace'
("guessPolynomialComplexity " ++ show (M.assocs xys))
bestOf
[cmpl1, cmpl2]
where
(cmpl1, cmpl2) = guessComplexityForFixedLog xys 0

guessComplexityForFixedLog
:: Map Word Measurement
-> Word
Expand Down

0 comments on commit 96f734c

Please sign in to comment.