Skip to content

Commit add2bdb

Browse files
authored
Merge pull request #20 from fehrenbach/master
Add console.time and timeEnd
2 parents eee71b1 + 1cf0268 commit add2bdb

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Effect/Class/Console.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ info = liftEffect <<< EffConsole.info
2929

3030
infoShow :: forall m a. MonadEffect m => Show a => a -> m Unit
3131
infoShow = liftEffect <<< EffConsole.infoShow
32+
33+
time :: forall m. MonadEffect m => String -> m Unit
34+
time = liftEffect <<< EffConsole.time
35+
36+
timeEnd :: forall m. MonadEffect m => String -> m Unit
37+
timeEnd = liftEffect <<< EffConsole.timeEnd

src/Effect/Console.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,17 @@ exports.info = function (s) {
2727
return {};
2828
};
2929
};
30+
31+
exports.time = function (s) {
32+
return function () {
33+
console.time(s);
34+
return {};
35+
};
36+
};
37+
38+
exports.timeEnd = function (s) {
39+
return function () {
40+
console.timeEnd(s);
41+
return {};
42+
};
43+
};

src/Effect/Console.purs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ foreign import info
4444
-- | `String`.
4545
infoShow :: forall a. Show a => a -> Effect Unit
4646
infoShow a = info (show a)
47+
48+
-- | Start a named timer.
49+
foreign import time :: String -> Effect Unit
50+
51+
-- | Stop a named timer and print time since it started in milliseconds.
52+
foreign import timeEnd :: String -> Effect Unit

0 commit comments

Comments
 (0)