title: Timing command execution in haskell
body: <p>I have a piece of code looking like this:</p>
  
  <pre><code>start &lt;- getCPUTime
  (_, _, _, ph) &lt;- createProcess (shell shellCmd) 
  end &lt;- (waitForProcess ph &gt;&gt; getCPUTime)
  print start
  print end
  </code></pre>
  
  <p>As you can see, the code is supposed to run a command <code>shellCmd</code> and print <code>getCPUTime</code> values before and after execution. However, it works incorrectly: time difference is always zero or <code>15625000000</code> (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.</p>
  
  <p>What's the right way of doing this, and why?</p>