Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
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
You can’t perform that action at this time.