From 70e3920556496e5fecb5fedddf1067b2522fcac7 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Tue, 24 Dec 2024 18:51:17 +0530 Subject: Add setup for ocr with tesseract --- src/Chelleport/Utils.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/Chelleport/Utils.hs') 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 -- cgit v1.3.1