I have a piece of code looking like this:
start <- getCPUTime
(_, _, _, ph) <- createProcess (shell shellCmd)
end <- (waitForProcess ph >> getCPUTime)
print start
print end
As you can see, the code is supposed to run a command shellCmd and print getCPUTime values before and after execution. However, it works incorrectly: time difference is always zero or 15625000000 (0.015 sec). As I understand, the reason is laziness, but can’t get how to fix it. I’ve found some examples on the Internet (one of those is above), and none of them worked for me.
What’s the right way of doing this, and why?
My first thought was that your shell command is really fast – perhaps even invalid. Then I read the documentation for
getCPUTime:So the process you fork off is not going to count toward your CPU time. Perhaps you want wall clock time via
getCurrentTimefromData.Time?