Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re^3: Linked lists as arrays: inserting values

by ikegami (Pope)
on Sep 25, 2006 at 23:37 UTC ( #574845=note: print w/replies, xml ) Need Help??

in reply to Re^2: Linked lists as arrays: inserting values
in thread Linked lists as arrays: inserting values

Here's my benchmarking code, demolish it at will:

First rule of Benchmarking, make sure the code you are benchmarking actually works!

@$ra = @$ra[0 ..$ index-1], $elem, @$ra[$index .. @$ra-1];
(@$ra = @$ra[0 ..$ index-1]), $elem, @$ra[$index .. @$ra-1];
You want
@$ra = ( @$ra[0 ..$ index-1], $elem, @$ra[$index .. @$ra-1] );

Also, your arguments are backwards:
insert1( \@ary, 1, $_ ) for $START .. $END
insert2( \@ary, 1 ,$_ ) for $START .. $END
should be
insert1( \@ary, $_, 1 ) for $START .. $END
insert2( \@ary ,$_, 1 ) for $START .. $END

Once fixed (and setting the loop count to -3 cause it was taking forever):

>perl 500 600 1000 Array size: 1000 Inserting: 500 .. 600 Rate radiant splicing radiant 17.3/s -- -99% splicing 1470/s 8392% --

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://574845]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2016-10-24 06:23 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (303 votes). Check out past polls.