Skip to content

Commit

Permalink
🧩 [consolidate]: preciseTime as local.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyp committed Oct 10, 2023
1 parent 9c2488a commit 94db95d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/Benchmark/Util.purs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,16 @@ instance Semigroup BenchRow where
instance Monoid BenchRow where
mempty = BenchRow M.empty

preciseTime :: forall m. MonadEffect m => m Number
preciseTime = liftEffect microtime

bench :: forall m a. MonadEffect m => MonadWriter BenchRow m => String -> (Unit -> m a) -> m a
bench name prog = do
t1 <- preciseTime
r <- prog unit
t2 <- preciseTime
tell (BenchRow $ singleton name (t2 `sub` t1))
pure r
where
preciseTime :: m Number
preciseTime = liftEffect microtime

divRow :: BenchRow -> Int -> BenchRow
divRow (BenchRow row) n = BenchRow (map (_ `div` toNumber n) row)

divRow (BenchRow row) n = BenchRow ((_ `div` toNumber n) <$> row)

0 comments on commit 94db95d

Please sign in to comment.