Last active
February 25, 2017 00:22
-
-
Save pventurino/14976b70568f8d0565ff7c8d62993fbf to your computer and use it in GitHub Desktop.
Salesforce algorithm performance testing template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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