Created
November 10, 2018 06:21
-
-
Save TheVishnuKumar/fe5b64dd906bb9964ec450f9f403a343 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 - Does System.Debug() cost CPU limit? | |
Author: 0to1Code.Com | |
*/ | |
public class ApexSpeedExperiment_1{ | |
//Experiment 1 : Without Debugs | |
public static void runExperiment1(){ | |
List<Lead> leadLst = [select id,name,company, Address, Industry, AnnualRevenue from lead limit 2000]; | |
system.debug('CPU Limit Consumption Start: '+Limits.getCPUtime()); | |
for( lead l : leadLst ){ | |
} | |
system.debug('CPU Limit Consumption End: '+Limits.getCPUtime()); | |
} | |
//Experiment 2 : With Debugs | |
public static void runExperiment2(){ | |
List<Lead> leadLst = [select id,name,company, Address, Industry, AnnualRevenue from lead limit 2000]; | |
system.debug('CPU Limit Consumption Start: '+Limits.getCPUtime()); | |
for( lead l : leadLst ){ | |
system.debug('Printing Debug: '+l); | |
} | |
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