1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
4 module Distribution
.Types
.Benchmark
9 , benchmarkModulesAutogen
12 import Distribution
.Compat
.Prelude
15 import Distribution
.Types
.BenchmarkInterface
16 import Distribution
.Types
.BenchmarkType
17 import Distribution
.Types
.BuildInfo
18 import Distribution
.Types
.UnqualComponentName
20 import Distribution
.ModuleName
22 import qualified Distribution
.Types
.BuildInfo
.Lens
as L
24 -- | A \"benchmark\" stanza in a cabal file.
25 data Benchmark
= Benchmark
26 { benchmarkName
:: UnqualComponentName
27 , benchmarkInterface
:: BenchmarkInterface
28 , benchmarkBuildInfo
:: BuildInfo
30 deriving (Generic
, Show, Read, Eq
, Ord
, Typeable
, Data
)
32 instance Binary Benchmark
33 instance Structured Benchmark
34 instance NFData Benchmark
where rnf
= genericRnf
36 instance L
.HasBuildInfo Benchmark
where
37 buildInfo f
(Benchmark x1 x2 x3
) = fmap (\y1
-> Benchmark x1 x2 y1
) (f x3
)
39 instance Monoid Benchmark
where
42 { benchmarkName
= mempty
43 , benchmarkInterface
= mempty
44 , benchmarkBuildInfo
= mempty
48 instance Semigroup Benchmark
where
51 { benchmarkName
= combineNames a b benchmarkName
"benchmark"
52 , benchmarkInterface
= combine benchmarkInterface
53 , benchmarkBuildInfo
= combine benchmarkBuildInfo
56 combine field
= field a `mappend` field b
58 emptyBenchmark
:: Benchmark
59 emptyBenchmark
= mempty
61 benchmarkType
:: Benchmark
-> BenchmarkType
62 benchmarkType benchmark
= case benchmarkInterface benchmark
of
63 BenchmarkExeV10 ver _
-> BenchmarkTypeExe ver
64 BenchmarkUnsupported benchmarktype
-> benchmarktype
66 -- | Get all the module names from a benchmark.
67 benchmarkModules
:: Benchmark
-> [ModuleName
]
68 benchmarkModules benchmark
= otherModules
(benchmarkBuildInfo benchmark
)
70 -- | Get all the auto generated module names from a benchmark.
71 -- This are a subset of 'benchmarkModules'.
72 benchmarkModulesAutogen
:: Benchmark
-> [ModuleName
]
73 benchmarkModulesAutogen benchmark
= autogenModules
(benchmarkBuildInfo benchmark
)