develooper Front page | perl.perl5.porters | Postings from December 2000

Re: [PATCH] Fcntl constants speedup

Thread Previous | Thread Next
Nicholas Clark
December 17, 2000 11:57
Re: [PATCH] Fcntl constants speedup
Message ID:
On Sun, Dec 17, 2000 at 11:27:32AM -0600, Jarkko Hietaniemi wrote:
> On Sun, Dec 17, 2000 at 04:29:24PM +0000, Nicholas Clark wrote:
> > Why do all the XS constant() routines (that I've looked at) have a second
> > unused integer argument after the name argument?
> > I assume that they return double because perl did all arithmetic (except
> > logical operations such as |) as doubles
> I think pretty much all the Perl XS extensions have started their life
> as h2xs outputs, even if they have been mucked around by hand quite
> extensively since then -- and h2xs still has these lines:
>     print $fh <<"END";
> static double
> constant(char *name, int len, int arg)
> {
>     errno = 0;
> Not even NV, "double".  Sigh.

But the "int len" for the string's length *is* a nifty idea.

So the guilding the lilly department presents a revised Fcntl.xs that
is faster (when you measure it over a 1,000,000 loop) *and* smaller.
Not that this really makes any noticeable difference to the regression
tests. :-) But it's the thought of it being faster that counts.

   text    data     bss     dec     hex filename
   5944       0       0    5944    1738 ext/Fcntl/Fcntl.o

All tests successful.
u=1.77  s=0.47  cu=71.86  cs=10.67  scripts=270  tests=20850

real    2m20.023s
user    1m13.630s
sys     0m11.140s

   text    data     bss     dec     hex filename
   5512       0       0    5512    1588 ext/Fcntl/Fcntl.o

All tests successful.
u=1.65  s=0.47  cu=71.12  cs=11.93  scripts=270  tests=20850

real    2m15.466s
user    1m12.770s
sys     0m12.400s

(and I get more variation in those timings than the difference between
them. Benchmarking the constant code shows it to be slightly faster)

not-a-patch because the patch would be longer than the file.
You don't have to use this if you don't feel the need.

Nicholas Clark
Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About