in reply to list of scalars vs arrays, speed?

I'd be curious to see what happens if you reverse the order of the tests.


Update: belg4mit rightly called me for being ambiguous. The naive way of reversing the order (i.e., swapping the elements in the hash that's passed to timethis()) won't work. You need to invoked timethis() once per test. The idea of reversing the order is to factor out memory fragmentation effects that biase towards the first test.

Replies are listed 'Best First'.
Re: Re: list of scalars vs arrays, speed?
by belg4mit (Prior) on May 02, 2002 at 06:21 UTC
    Order? The subs are passed as a hashref, user has no control over order. He'd have to call timethis twice.

    --
    perl -pew "s/\b;([mnst])/'$1/g"

      He'd have to call timethis twice.

      How, exactly, is that a problem?

        Oh, it's not a problem. However the way you worded your response did not acutally convey that that was what you were suggesting. Taking your comment literally one might naively do:
        @base=qw/one two three four five six seven/; timethese(1_000_000,{ '@'=>sub{@s=@base;} '$'=>sub {($s1,$s2,$s3,$s4,$s5,$s6,$s7)=@base;}, });

        --
        perl -pew "s/\b;([mnst])/'$1/g"