title: How to measure time taken by a function to execute
body: <p>I need to get execution time in milliseconds.</p>
  <blockquote>
  <p>I originally asked this question back in 2008. The accepted answer then was to use <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime" rel="noreferrer"><code>new Date().getTime()</code></a> However, we can all agree now  that using the standard <a href="https://developer.mozilla.org/en-US/docs/Web/API/Performance.now" rel="noreferrer"><code>performance.now()</code></a> API is more appropriate. I am therefore changing the accepted answer to this one.</p>
  </blockquote>