Skip to content

Instantly share code, notes, and snippets.

@imtrinity94
Last active March 21, 2022 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imtrinity94/649bcb80ee654c30e574b1dabe89f854 to your computer and use it in GitHub Desktop.
Save imtrinity94/649bcb80ee654c30e574b1dabe89f854 to your computer and use it in GitHub Desktop.
// To test a function and get back its return
function printElapsedTime(fTest) {
var StartTime = Date.now(),
vReturn = fTest(),
EndTime = Date.now(),
difference = EndTime-StartTime
System.log("Elapsed time: "+difference+" milliseconds") //5001 milliseconds
return vReturn
}
var yourFunctionReturn = printElapsedTime(sort)
function sort(){ // your function
const array1 = [1, 30, 4, 21, 100000];
array1.sort();
System.log(array1);
System.sleep(5000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment