Chris Devers wrote:
On Thu, 13 Jan 2005, Dave Kettmann wrote:
[...] Some of the time I see them say that the [strict / warnings] pragmas are good for developing programs/scripts. The way it is worded some times it seems as if after the program is written and in 'production' to take these lines out of the code. Do they slow down how perl processes the programs? Does it hurt to leave them in?
No, leave them in, always.
Yep!
There should be little if any noticable speed difference.
Also 100% correct:
I did a benchmark of use strict; use warnings; print 1; vs. print 1;
Benchmark: timing 10000000 iterations of no pragma, w/ pragma...
no pragma: 4.9282 wallclock secs ( 4.79 usr + 0.01 sys = 4.80 CPU) @ 2083333.33/s (n=10000000)
w/ pragma: 4.97848 wallclock secs ( 4.95 usr + -0.01 sys = 4.94 CPU) @ 2024291.50/s (n=10000000)
Rate w/ pragma no pragma
w/ pragma 2024291/s -- -3%
no pragma 2083333/s 3% --
So it costs 3% more every ten million times it runs, the benefits of leaving it in are much more valuabel than 3%/10000000 :)
Actually, what happens is that importing those pragma cause flags to be set (eg $^H, see `perldoc perlvar`). Perl checks these flags during certain operations. If the flags are set then perl will do extra checking in the case of strict.pm and also emit warnings in the case of warnings.pm, so your benchmark doesn't really measure the cost. You'd have to benchmark on a project by project basis.
Not that I'm trying persuade anyone against using them. As I said, I pretty much always use them. Any needed optimizations can usually be found elsewhere.
Randy.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>