summaryrefslogtreecommitdiffhomepage
path: root/Cost.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-30 13:28:30 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-30 13:29:47 -0400
commite6a706517187c280be652afa54ee75893bdf9608 (patch)
treef7b073ede11ad51bd83972e8ce9c29712d2799a0 /Cost.hs
parent2106de31f7a8e37bb2ea8b8e9650a26dbef0d893 (diff)
downloadkeysafe-e6a706517187c280be652afa54ee75893bdf9608.tar.gz
add coreCost
Diffstat (limited to 'Cost.hs')
-rw-r--r--Cost.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/Cost.hs b/Cost.hs
index 3e3e2df..8936dec 100644
--- a/Cost.hs
+++ b/Cost.hs
@@ -27,6 +27,11 @@ showCostMinutes (CPUCost (Seconds n))
| n < 61 = "1 minute"
| otherwise = show (n `div` 60) ++ " minutes"
+-- If an operation took n seconds on a number of cores,
+-- multiple to get the CPUCost, which is for a single core.
+coreCost :: Integer -> Seconds -> Cost op
+coreCost cores (Seconds n) = CPUCost (Seconds (cores * n))
+
castCost :: Cost a -> Cost b
castCost (CPUCost s) = CPUCost s