# from Sisyphus
# on Friday 19 January 2007 02:39 am:

>Well ... I can't detect a significant difference for a 10,000,000
> element array of integers.

Surprisingly, the ref version is slower than the list version if you put 
it inside a bit of a loop.  That's actually counter to the pure-perl 
behavior.  I suppose the XS code is basically accessing the array ref 
already.

I stuck in a sum just to make sure there isn't too much optimizer magic 
happening.  Anyhow, yeah.  Use the list.  I think the subroutine call 
overhead shows up more dramatically if you move zeros from $elements to 
$times.

  http://scratchcomputing.com/tmp/bm_ref_vs_list.pl

Benchmark: timing 5 iterations of by_list, by_ref, perl_list, 
perl_ref...
   by_list:  4 wallclock secs (...) @  1.47/s (n=5)
    by_ref:  4 wallclock secs (...) @  1.35/s (n=5)
 perl_list: 28 wallclock secs (...) @  0.18/s (n=5)
  perl_ref: 25 wallclock secs (...) @  0.20/s (n=5)

--Eric
-- 
The only thing that could save UNIX at this late date would be a new $30
shareware version that runs on an unexpanded Commodore 64.
--Don Lancaster (1991)
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------

Reply via email to