views:

68

answers:

5

I have a job with around 100K records to process.

There are many print statements which get executed for each record. Does these print statements have any impact on performance?

For that matter, does number of lines or comments have any impact on performance? I want to save even a single ms if I can.

+4  A: 

Print definitely has an impact, while comments wouldn't as they are excluded whenever anything is compiled (unless the compiler is strange).

Zoidberg
(+1) Thanks Zoidberg!
noob.spt
+3  A: 
  • comments = no. Ignored by optimiser
  • prints = slightly. Sent in batches to client

Drop the PRINT statement if you need every millisecond... but consider what happens when you've no hints for troubleshooting and debugging. How many minutes would you lose?

gbn
(+1) Thank You!
noob.spt
+3  A: 

Yes. The biggest impact of PRINTs is that they have to be sent to the client. Ultimately, if the client does not process the informational messages, the server can even suspend execution because the communication pipe is full.

Remus Rusanu
(+1) Thank You!
noob.spt
+1  A: 

Apart from some interpreted languages, comments cost nothing.

You might save some time by combining multiple output text lines together and then printing them in groups. But that may be more effort than it's worth.

Loadmaster
A: 

If you need to save every possible millisecond, then if I were you I would do some serious performance tuning, as in this example.

Performance problems always have a positive cost, and as such, they can vary by large factors. So while printing things that aren't going to be read (especially formatting floating point numbers) can be a big performance problem, you may in fact have other, bigger performance problems that you should get rid of first.

Good luck.

Mike Dunlavey