<commit_before>{-# Language RankNTypes #-}
{-# Language TypeOperators #-}
{-# Language BangPatterns #-}

module IO where

-- import Data.Array
import Prelude hiding (traverse)
import Data.Vector hiding (force)
import qualified Data.Vector as V
import Data.Array.Repa
import Types
import System.CPUTime
import Data.Array.Repa.IO.DevIL
import Data.Word
import qualified Data.Array.Repa as R
import Debug.Trace
import System.Directory
import Control.Exception
import Control.DeepSeq
import Data.Array.Repa.Repr.ForeignPtr
import System.IO.Error hiding (catch)
import Data.Array.Accelerate.IO
import qualified Data.Array.Accelerate as A
import Text.Printf
import qualified Codec.Picture as Codec
import Control.DeepSeq
import Data.Time.Clock


printDiff :: UTCTime -> UTCTime -> IO ()
printDiff start end = do
--  print (realToFrac (diffUTCTime end start) :: Double)
  let s = show (diffUTCTime end start)
  putStrLn (Prelude.init s) -- drops the "s" from the end

-- | time monadic computation.
printTimeIO :: IO a -> IO a
printTimeIO action = do
  start <- getCurrentTime
  a <- action
  end   <- getCurrentTime
  printDiff start end
  return a

-- see about the following benchmark
-- https://github.com/AccelerateHS/accelerate/issues/208

-- | time evaluation of pure computation, in picoseconds.
printTime :: a -> IO a
printTime f = do
  start <- getCurrentTime
  end <- seq f getCurrentTime
  printDiff start end
  return f<commit_msg>(Haskell) fix the way runtime is printed<commit_after>{-# Language RankNTypes #-}
{-# Language TypeOperators #-}
{-# Language BangPatterns #-}

module IO where

-- import Data.Array
import Prelude hiding (traverse)
import Data.Vector hiding (force)
import qualified Data.Vector as V
import Data.Array.Repa
import Types
import System.CPUTime
import Data.Array.Repa.IO.DevIL
import Data.Word
import qualified Data.Array.Repa as R
import Debug.Trace
import System.Directory
import Control.Exception
import Control.DeepSeq
import Data.Array.Repa.Repr.ForeignPtr
import System.IO.Error hiding (catch)
import Data.Array.Accelerate.IO
import qualified Data.Array.Accelerate as A
import Text.Printf
import qualified Codec.Picture as Codec
import Control.DeepSeq
import Data.Time.Clock


printDiff :: UTCTime -> UTCTime -> IO ()
printDiff start end = do
  let s = show (diffUTCTime end start)
  putStrLn (Prelude.init s) -- drops the "s" from the end

-- | time monadic computation.
printTimeIO :: IO a -> IO a
printTimeIO action = do
  start <- getCurrentTime
  a <- action
  end   <- getCurrentTime
  printDiff start end
  return a

-- see about `seq` in the following benchmark
-- https://github.com/AccelerateHS/accelerate/issues/208

-- | time evaluation of pure computation, in picoseconds.
printTime :: a -> IO a
printTime f = do
  start <- getCurrentTime
  end <- seq f getCurrentTime
  printDiff start end
  return f
{'fraction_non_alphanumeric': 0.08973010865755346, 'fraction_numerical': 0.002103049421661409, 'mean_word_length': 3.954861111111111, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2969521', 'n_tokens_mistral': 900, 'n_tokens_neox': 872, 'n_words': 309}