Will unnecessary Serial.print() statements slow down my program? I have lots of Serial.print() and Serial.println() statements throughout my (rather large) program for debugging when things fail. I've commented out the Serial.begin() statement so I don't slow down execution by running a serial port. However, I'd like to leave the Serial.print() calls so I only have to uncomment Serial.begin() later on.

If there is no Serial port active on the device, are the Serial.print() lines still executed at runtime, or does the compiler ignore them? Is there any performance advantage to explicitly commenting out those lines?
No, there is no USART wasn't enabled so skip all prints. Everything must be done anyways (calls, conversions to strings, writes to UDR - USART Data Register). It is just not sent outside by USART and it doesn't have to wait for UDRE (USART Data Register Empty flag) so it might be slightly faster.

You can use similar technique as Loggers - log level variable and ifs (this can be changed runtime).

Or you can use macros:

// comment out this line, if you want to show logs:
#define NDEBUG

#ifdef NDEBUG
  #define LOG(...)
  #define LOGLN(...)
#else
  #define LOG(...) Serial.print(__VA_ARGS__)
  #define LOGLN(...) Serial.println(__VA_ARGS__)
#endif


And later:

LOG(F("Something: 0x"));
LOGLN(variable, HEX);


And how it looks after macro substitution? For code:

if (...) LOG(F("something")); else LOG(F("something else"));


With NDEBUG defined it's expanded to:

if (...) ; else ;


And without NDEBUG defined it's expanded to:

if (...) Serial.print(F("something")); else Serial.print(F("something else"));