On Sat, 28 Mar 2009, tokuhirom@gmail.com via RT wrote:
Show quoted text> XS version is not a fast in my environment.
>
> benchmark score is here:
> -- 0.91 pp ver
> 5.010000
> pp ver
> Benchmark: timing 100000 iterations of complex, simple...
> complex: 9 wallclock secs ( 8.58 usr + 0.00 sys = 8.58 CPU) @
> 11655.01/s (n=100000)
> simple: 5 wallclock secs ( 5.19 usr + 0.00 sys = 5.19 CPU) @
> 19267.82/s (n=100000)
>
> -- 0.91 xs ver
> 5.010000
> xs ver
> Benchmark: timing 100000 iterations of complex, simple...
> complex: 8 wallclock secs ( 7.47 usr + 0.00 sys = 7.47 CPU) @
> 13386.88/s (n=100000)
> simple: 5 wallclock secs ( 5.28 usr + 0.00 sys = 5.28 CPU) @
> 18939.39/s (n=100000)
>
> -- 0.91 pp ver + my patch
> 5.010000
> pp ver
> Benchmark: timing 100000 iterations of complex, simple...
> complex: 8 wallclock secs ( 7.60 usr + 0.00 sys = 7.60 CPU) @
> 13157.89/s (n=100000)
> simple: 4 wallclock secs ( 4.15 usr + 0.00 sys = 4.15 CPU) @
> 24096.39/s (n=100000)
>
> looks like a pp ver + my patch is faster than xs version.why??
> how to get a 2x score?
I think there's a couple things going on here.
First, the validations you're doing are pretty simple, even the complex
one.
The more validation you do per call, the more noticeable the XS version
is.
Second, I probably misremembered the actual speed increase. I think it's
maybe more like 1.5x as fast (or a little more) in some cases.
Also, the last time I did a lot of benchmarking was when the XS was
released, back in 2003. It's quite possible that on a modern computer,
with a modern Perl, things have changed.
I did try applying your patch, but it didn't seem to make much difference.
There's also a benchmark in the Params::Validate repo
https://svn.urth.org/svn/Params-Validate/trunk/
What's interesting is that for the simplest validations in that benchmark,
pure Perl is _faster_. For the more complex ones, the XS version is
anywhere from 25-60% faster.
-dave
/*============================================================
http://VegGuide.org http://blog.urth.org
Your guide to all that's veg House Absolute(ly Pointless)
============================================================*/