Skip to content

Commit

Permalink
Export analysis related functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Mattia committed Jan 3, 2018
1 parent 2756ec7 commit 9ebe1e4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/end-to-end-benchmarks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ benchmarks =
main :: IO ()
main = defaultMainWith config "hyperion-example-end-to-end" benchmarks
where
config = defaultConfig
config = defaultConfigMonoid
{ configMonoidSamplingStrategy =
pure $ timeBound (fromSeconds 5) (repeat 10)
}
Expand Down
13 changes: 10 additions & 3 deletions src/Hyperion/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
module Hyperion.Main
( defaultMain
, Mode(..)
, Config(..)
, ConfigMonoid(..)
, ReportOutput(..)
, nullOutputPath
, defaultConfig
, defaultConfigMonoid
, defaultMainWith
, doAnalyze
, doRun
) where

import Control.Applicative
Expand Down Expand Up @@ -178,8 +182,11 @@ nullOutputPath = "nul"
nullOutputPath = "/dev/null"
#endif

defaultConfig :: ConfigMonoid
defaultConfig = mempty
defaultConfigMonoid :: ConfigMonoid
defaultConfigMonoid = mempty

defaultConfig :: Config
defaultConfig = configFromMonoid defaultConfigMonoid

data DuplicateIdentifiers a = DuplicateIdentifiers [a]
instance (Show a, Typeable a) => Exception (DuplicateIdentifiers a)
Expand Down Expand Up @@ -315,4 +322,4 @@ defaultMain
:: String -- ^ Package name, user provided.
-> [Benchmark] -- ^ Benchmarks to be run.
-> IO ()
defaultMain = defaultMainWith defaultConfig
defaultMain = defaultMainWith defaultConfigMonoid
6 changes: 4 additions & 2 deletions tests/Hyperion/MainSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ spec = do
it "checks for duplicate identifiers" $ property $ \b ->
length (b^..identifiers) /= length (group (sort (b^..identifiers))) ==>
expectFailure $ monadicIO $ run $
defaultMainWith defaultConfig{configMonoidMode = return Run} "spec" [b]
defaultMainWith
defaultConfigMonoid{configMonoidMode = return Run} "spec" [b]
it "Analyzes uniquely identified benchmarks" $ property $ \b ->
length (b^..identifiers) == length (group (sort (b^..identifiers))) ==>
monadicIO $ run $
defaultMainWith defaultConfig{configMonoidReportOutputs = [ReportJson nullOutputPath]} "specs" [b]
defaultMainWith
defaultConfigMonoid{configMonoidReportOutputs = [ReportJson nullOutputPath]} "specs" [b]

0 comments on commit 9ebe1e4

Please sign in to comment.