This question is related to the following question : How to force evaluation in Haskell?
I want to benchmark the algorithm quicksort for a list. For this I have made a certain number of files which have random numbers in them.
Here is the relevant part of the code in question :
import System.IO
import Data.Time
import Control.DeepSeq
getListFromFiles :: IO [[Int]]
quicksort :: (Ord a) => [a] -> [a]
main = do
l <- getListFromFiles
start <- getCurrentTime
let l' = map quicksort l
end <- l' `deepseq` getCurrentTime
print (diffUTCTime end start)
I do not want to know want to measure the time the program takes to look into the files, just the one that the sorting takes. Because of laziness, I think that the list l is only evaluated when deepseq is called on the list l' and that gives a flawed benchmark. Am I correct ?