Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- funcTimer(output, funcName, boolReturn, callback){
- var t0 = new Date().getTime();
- var returnValue = callback();
- if ( output === "console" ) {
- if ( !funcName && boolReturn ){
- var t1 = new Date().getTime();
- console.log( "Function took " + (t1 - t0) + " milliseconds." );
- return returnValue;
- }
- else if ( !funcName && !boolReturn ) {
- var t1 = new Date().getTime();
- console.log( "Function took " + (t1 - t0) + " milliseconds." );
- return;
- }
- else if ( funcName && boolReturn ) {
- var t1 = new Date().getTime();
- console.log( funcName + " took " + (t1 - t0) + " milliseconds." );
- return returnValue;
- } else if ( funcName && !boolReturn ) {
- var t1 = new Date().getTime();
- console.log( funcName + " took " + (t1 - t0) + " milliseconds." );
- return;
- }
- } else {
- console.log("Error: First argument must be output type: console");
- return;
- }
- // other output types go here
- }
Add Comment
Please, Sign In to add comment