Thanks for replying. I did some benchmarks today. Staggering.
B1:
timethese(2000, { 'log_error' => sub { $r->log_error("benchmarking log_error") }, 'STDERR' => sub { print STDERR "benchmarking log_error\n" }, });
Result:
Benchmark: timing 2000 iterations of STDERR, log_error...
STDERR: 0 wallclock secs ( 0.00 usr + 0.02 sys = 0.02 CPU) @ 125000.00/s (n=2000)
(warning: too few iterations for a reliable count)
log_error: 37 wallclock secs ( 0.06 usr + 0.56 sys = 0.62 CPU) @ 3200.00/s (n=2000)
B2:
I then added localtime() to STDERR to see if that could slow it down a bit:
timethese(2000, {
'log_error' => sub { $r->log_error("benchmarking log_error") },
'STDERR' => sub { print STDERR '['.scalar(localtime())."] [error] benchmarking log_error\n" },
});
Result:
Benchmark: timing 2000 iterations of STDERR, log_error...
STDERR: 0 wallclock secs ( 0.03 usr + 0.00 sys = 0.03 CPU) @ 64516.13/s (n=2000)
(warning: too few iterations for a reliable count)
log_error: 40 wallclock secs ( 0.05 usr + 0.50 sys = 0.55 CPU) @ 3663.00/s (n=2000)
Still below 1 second but the rate has dropped to the half.
B3:
I then dit a 100000 iteration timing of just STDERR (with localtime()):
Benchmark: timing 100000 iterations of STDERR...
STDERR: 2 wallclock secs ( 1.20 usr + 0.63 sys = 1.83 CPU) @ 54704.60/s (n=100000)
Nice if someone could benchmark this on unix/linux as well to see if it's a win32 issue.
-Kurt.
Stas Bekman wrote:
Kurt George Gjerde wrote:
Hi,
Are there any reasons why $r->log_error($msg) is (much) slower than print STDERR '['.scalar(localtime()).'] [error] '.$msg."\n" ?
Both are producing the same output (except that the latter goes to the main error_log, and the former to the virtual host error log).
This is happening on win32: Apache/2.0.48 (Win32) mod_perl/1.99_12-dev Perl/v5.8.0 (latest from theoryx5).
A perl-script writing two lines to error_log takes 50ms using $r->log_error and only 15ms using STDERR. Timings are from: ab -n 50 ...
Have you tried benchmarking the calls themselves using Benchmark, instead of a whole request? We just provide a perl interface for ap_log_error, so it's possible that the C call is slow.
__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
-- Kurt George Gjerde [EMAIL PROTECTED] ICQ:156792385
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]