diff options
Diffstat (limited to 'Types/Cost.hs')
-rw-r--r-- | Types/Cost.hs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Types/Cost.hs b/Types/Cost.hs index 0e017bb..372c43d 100644 --- a/Types/Cost.hs +++ b/Types/Cost.hs @@ -9,22 +9,26 @@ module Types.Cost where -- | An estimated cost to perform an operation. data Cost op - = CPUCost Seconds -- ^ using 1 physical CPU core + = CPUCost Seconds Divisibility + -- ^ cost in Seconds, using 1 physical CPU core deriving (Show, Eq, Ord) -unknownCost :: Cost op -unknownCost = CPUCost (Seconds 0) - newtype Seconds = Seconds Integer deriving (Num, Eq, Ord, Show) +-- | How many CPU cores a single run of an operation can be divided amoung. +newtype Divisibility = Divisibility Integer + deriving (Show, Eq, Ord) + data UsingHardware = UsingCPU | UsingGPU | UsingASIC deriving (Show) instance Monoid (Cost t) where - mempty = CPUCost (Seconds 0) - CPUCost (Seconds a) `mappend` CPUCost (Seconds b) = - CPUCost (Seconds (a+b)) + mempty = CPUCost (Seconds 0) (Divisibility 1) + CPUCost (Seconds a) (Divisibility x) `mappend` CPUCost (Seconds b) (Divisibility y) = + -- Take maximum divisibility, to avoid over-estimating + -- the total cost. + CPUCost (Seconds (a+b)) (Divisibility $ max x y) -- | Operations whose cost can be measured. data DecryptionOp |