diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-06-11 16:25:37 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-06-11 16:34:35 -0400 |
commit | d00807c002eecf53efd1967416341a0bbf7ed2d3 (patch) | |
tree | 5875dd0081487bb951b02281151677843135338e /Utility | |
parent | 671f5025df40937429a6ee85b54d7b3e70ca55f1 (diff) |
4 ns optimisation of repeated calls to hasDifference on the same Differences
I want this as fast as possible, so it can be added to code paths without
slowing them down.
Avoid the set lookup, and rely on laziness,
drops runtime from 14.37 ns to 11.03 ns according to this criterion benchmark:
import Criterion.Main
import qualified Types.Difference as New
import qualified Types.DifferenceOld as Old
main :: IO ()
main = defaultMain
[ bgroup "hasDifference"
[ bench "new" $ whnf (New.hasDifference New.OneLevelObjectHash) new
, bench "old" $ whnf (Old.hasDifference Old.OneLevelObjectHash) old
]
]
where
s = "fromList [ObjectHashLower, OneLevelObjectHash, OneLevelBranchHash]"
new = New.readDifferences s
old = Old.readDifferences s
A little bit of added boilerplate, but I suppose it's worth it to not
need to worry about set lookup overhead. Note that adding more differences
would slow down the old implementation; the new implementation will run
the same speed.
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/URI.hs | 8 |
1 files changed, 0 insertions, 8 deletions
diff --git a/Utility/URI.hs b/Utility/URI.hs index e68fda58d..1e2129a47 100644 --- a/Utility/URI.hs +++ b/Utility/URI.hs @@ -8,11 +8,3 @@ {-# LANGUAGE CPP #-} module Utility.URI where - --- Old versions of network lacked an Ord for URI -#if ! MIN_VERSION_network(2,4,0) -import Network.URI - -instance Ord URI where - a `compare` b = show a `compare` show b -#endif |