aboutsummaryrefslogtreecommitdiff
path: root/src/Chelleport/Utils.hs
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2024-12-24 18:51:17 +0530
committerAkshay Nair <phenax5@gmail.com>2024-12-24 18:51:17 +0530
commit70e3920556496e5fecb5fedddf1067b2522fcac7 (patch)
tree7e4e88023bdcd5b13dde738f7afedd533a6d7fcd /src/Chelleport/Utils.hs
parentdfdf1600ba251f6b3cfef85f6904d79a1c60b49d (diff)
downloadchelleport-70e3920556496e5fecb5fedddf1067b2522fcac7.tar.gz
chelleport-70e3920556496e5fecb5fedddf1067b2522fcac7.zip
Add setup for ocr with tesseract
Diffstat (limited to 'src/Chelleport/Utils.hs')
-rw-r--r--src/Chelleport/Utils.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Chelleport/Utils.hs b/src/Chelleport/Utils.hs
index 0e7dabc..c15a3e8 100644
--- a/src/Chelleport/Utils.hs
+++ b/src/Chelleport/Utils.hs
@@ -1,6 +1,9 @@
module Chelleport.Utils where
+import Control.Monad.IO.Class (MonadIO (liftIO))
import Data.List (nub)
+import Data.Time.Clock.System (SystemTime (systemNanoseconds), getSystemTime)
+import qualified Debug.Trace as Debug
import Foreign.C (CInt)
intToCInt :: Int -> CInt
@@ -24,3 +27,11 @@ isEmpty = null
isNotEmpty :: [a] -> Bool
isNotEmpty = not . isEmpty
+
+benchmark :: (MonadIO m) => String -> m a -> m a
+benchmark msg m = do
+ start <- systemNanoseconds <$> liftIO getSystemTime
+ result <- m
+ end <- systemNanoseconds <$> liftIO getSystemTime
+ Debug.traceM $ msg ++ " (ms): " ++ show (fromIntegral (end - start) / 1_000_000.0 :: Double)
+ pure result