Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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];
means
(@$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 574845.pl 500 600 1000 Array size: 1000 Inserting: 500 .. 600 Rate radiant splicing radiant 17.3/s -- -99% splicing 1470/s 8392% --


Comment on Re^3: Linked lists as arrays: inserting values
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-08-23 16:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (174 votes), past polls