Skip to content

Instantly share code, notes, and snippets.

@pventurino
Last active February 25, 2017 00:22
Show Gist options
  • Save pventurino/14976b70568f8d0565ff7c8d62993fbf to your computer and use it in GitHub Desktop.
Save pventurino/14976b70568f8d0565ff7c8d62993fbf to your computer and use it in GitHub Desktop.
Salesforce algorithm performance testing template
/*
* Use to compare the performance of two or more algorithms
* in Salesforce that should bear the same result.
* Also available in http://pastebin.com/XDAtu4ip
*/
Integer loops = 1000;
Datetime stime, etime; // Start time, end time
String results = '';
void logtime(String msg) {
results += '\n' + msg + ': ' + (etime.getTime() - stime.getTime()) + ' ms';
}
// Repeat this snippet for each strategy
stime = System.now();
for (Integer i=0; i<loops; i++) {
// Write your strategy here
}
etime = System.now();
logtime('Your strategy');
System.debug(results);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment