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