Last active
November 14, 2018 04:56
-
-
Save TheVishnuKumar/3085c933c008dddfb9f7dd172bf1486a to your computer and use it in GitHub Desktop.
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
/* | |
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()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment