Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 0.36 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. measuring the memory usage, execution time, and performance of a JavaScript function
  2. function foo(){ var x = new Object();}
  3.        
  4. function bar(){var x = {};}
  5.        
  6. var start = new Date().getTime();
  7. *Your Code*
  8. var end = new Date().getTime(),
  9.     time = end - start,
  10.     execs = 1000 / time;
  11.  
  12. console.log('time in ms: '+time);
  13. console.log('operations per second: '+execs);