title: How can I measure CPU time and wall clock time on both Linux/Windows?
body: <p>I mean: how can I measure time my CPU spent on function execution and wall clock time it takes to run my function? (Im interested in Linux/Windows and both x86 and x86_64). See what I want to do (Im using C++ here but I would prefer C solution):</p>
  
  <pre><code>int startcputime, endcputime, wcts, wcte;
  
  startcputime = cputime();
  function(args);
  endcputime = cputime();
  
  std::cout &lt;&lt; "it took " &lt;&lt; endcputime - startcputime &lt;&lt; " s of CPU to execute this\n";
  
  wcts = wallclocktime();
  function(args);
  wcte = wallclocktime();
  
  std::cout &lt;&lt; "it took " &lt;&lt; wcte - wcts &lt;&lt; " s of real time to execute this\n";
  </code></pre>
  
  <p><strong>Another important question: is this type of time measuring architecture independent or not?</strong></p>