Am Mittwoch 17 Juni 2009 20:25:08 schrieb Nico Rolle: > Hi everyone. > I made parallel versions of my functions projection selection and sort > and i wanted to test the difference in runtime. > But he only printed 0.00 twice. > Maybe hes just too fast? > Or is it because of lazy evaluation? > or is there a better way to mesure performance in execution time? > regards > > main = do > xs <- readCSV "dataconvert/lineitem.tbl" '|' > start <- getCurrentTime > let pnp = projection [5] xs > let snp = selection (\x -> (x!!0) > (Int 17000)) pnp > let sortnp = sort [0] [ASC] snp > end <- getCurrentTime > putStrLn $ show (end `diffUTCTime` start) > start2 <- getCurrentTime > let pp = pProjection [5] xs > let sp = pSelection (\x -> (x!!0) > (Int 17000)) pp > let sortp = pSort [0] [ASC] sp > end2 <- getCurrentTime > putStrLn $ show (end2 `diffUTCTime` start2) > return snp
The let bindings do not cause any computation because of laziness, all they do is bind the names to a thunk that says how to calculate the value if it is needed. Regardless of how long the computation would take, binding the names to a thunk takes only a few nanoseconds. To measure the time needed for the computations, you must force them to be carried out between the two calls to getCurrentTime. Probably inserting print $ last snp before end <- getCurrentTime (and likewise for the second) would be enough (if the sorting doesn't require the values in snp to be fully evaluated, you would have to do more forcing). _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe