+ Start a Discussion
James L.James L. 

will System.debug, if left in production, affect performance ?

If put some system.debug statments in the code and keep them in the production. will that affect performance?

I'm using them to do exception tracking

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Code executed, including System.Debug and System.assert (and their variants) have the following effects:

 

1) They increase debug log sizes.

2) They increase script execution time (but insignificantly).

3) They count against governor limits.

 

The final bullet point is your most troubling concern. A loop against 1000 records with 10 debug statements will have a total of 10,000 extra script statements than the one without. The salesforce.com best practices state that you should always remove or comment debug statements for production code (part of the security review docs).

 

Edit: One final note, your code shouldn't need debug statements. That's what Test Methods are for.

All Answers

sfdcfoxsfdcfox

Code executed, including System.Debug and System.assert (and their variants) have the following effects:

 

1) They increase debug log sizes.

2) They increase script execution time (but insignificantly).

3) They count against governor limits.

 

The final bullet point is your most troubling concern. A loop against 1000 records with 10 debug statements will have a total of 10,000 extra script statements than the one without. The salesforce.com best practices state that you should always remove or comment debug statements for production code (part of the security review docs).

 

Edit: One final note, your code shouldn't need debug statements. That's what Test Methods are for.

This was selected as the best answer
James L.James L.

Thanks