Guest User

Untitled

a guest
Jan 18th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. funcTimer(output, funcName, boolReturn, callback){
  2. var t0 = new Date().getTime();
  3. var returnValue = callback();
  4. if ( output === "console" ) {
  5. if ( !funcName && boolReturn ){
  6. var t1 = new Date().getTime();
  7. console.log( "Function took " + (t1 - t0) + " milliseconds." );
  8. return returnValue;
  9. }
  10. else if ( !funcName && !boolReturn ) {
  11. var t1 = new Date().getTime();
  12. console.log( "Function took " + (t1 - t0) + " milliseconds." );
  13. return;
  14. }
  15. else if ( funcName && boolReturn ) {
  16. var t1 = new Date().getTime();
  17. console.log( funcName + " took " + (t1 - t0) + " milliseconds." );
  18. return returnValue;
  19. } else if ( funcName && !boolReturn ) {
  20. var t1 = new Date().getTime();
  21. console.log( funcName + " took " + (t1 - t0) + " milliseconds." );
  22. return;
  23. }
  24. } else {
  25. console.log("Error: First argument must be output type: console");
  26. return;
  27. }
  28. // other output types go here
  29. }
Add Comment
Please, Sign In to add comment