Skip to content

Instantly share code, notes, and snippets.

@TheVishnuKumar
Created November 10, 2018 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheVishnuKumar/fe5b64dd906bb9964ec450f9f403a343 to your computer and use it in GitHub Desktop.
Save TheVishnuKumar/fe5b64dd906bb9964ec450f9f403a343 to your computer and use it in GitHub Desktop.
/*
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