Time Execution Javascript


/ Published in: JavaScript
Save to your folder(s)

Javascript time execution utility:
Use:

var otd = new timeDebugger();
otd.start();
alert(otd.end());


Copy this code and paste it in your HTML
  1. function timeDebugger() { };
  2.  
  3. timeDebugger.prototype.d = new Date();
  4. timeDebugger.prototype.t = new Date();
  5.  
  6. timeDebugger.prototype.start = function() {
  7. this.d = new Date();
  8. this.t = this.d.getTime();
  9. };
  10.  
  11. timeDebugger.prototype.end = function() {
  12. this.d = new Date();
  13. return (this.d.getTime() - this.t);
  14. };

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.