Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Speed Test - Which One is Fast to Compare String from ==, equals and equalsIgnoreCase
- Author: 0to1Code.Com
- */
- public class ApexSpeedExperiment_3{
- //Experiment 1 : Using ==
- public static void runExperiment1(){
- system.debug('CPU Limit Consumption Start: '+Limits.getCPUtime());
- for(Integer i=0; i<50000 ;i++){
- if( 'Test'=='Test' ){}
- }
- system.debug('CPU Limit Consumption End: '+Limits.getCPUtime());
- }
- //Experiment 2 : Using equals method
- public static void runExperiment2(){
- system.debug('CPU Limit Consumption Start: '+Limits.getCPUtime());
- for(Integer i=0; i<50000 ;i++){
- if( 'Test'.equals('Test') ){}
- }
- system.debug('CPU Limit Consumption End: '+Limits.getCPUtime());
- }
- //Experiment 3 : Using equalsIgnoreCase method
- public static void runExperiment3(){
- system.debug('CPU Limit Consumption Start: '+Limits.getCPUtime());
- for(Integer i=0; i<50000 ;i++){
- if( 'Test'.equalsIgnoreCase('Test') ){}
- }
- system.debug('CPU Limit Consumption End: '+Limits.getCPUtime());
- }
- }
Add Comment
Please, Sign In to add comment