Perl newbie

Mar. 2nd, 2006 09:36 am
ocehb: (Default)
[personal profile] ocehb
нашел в одном месте задачку на упрощение: мой вариант: sort { (keys %$a)[0] <=> (keys %$b)[0] }. Benchmark на

foreach (1..1024) {
        push @ary,{ int (rand 102400)%$ARGV[0] => "a" . int (rand (1024)) };
}
...
timethese (102400,{ 'a1' => sub { a1 (@ary); },'a2' => sub { a2 (@ary); } })

такой:
Benchmark: timing 102400 iterations of a1, a2...
        a1: 520 wallclock secs (489.74 usr +  0.34 sys = 490.08 CPU) @ 208.95/s (n=102400)
        a2:  1 wallclock secs ( 0.92 usr +  0.00 sys =  0.92 CPU) @ 111304.35/s (n=102400)
Real: 521.32s User: 490.93s System: 0.36s Percent: 94%% Cmd: perl a.pl 1024 102400
А у вас? :)
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org

Profile

ocehb: (Default)
ocehb

January 2021

S M T W T F S
     12
345 6789
10111213141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 11th, 2025 11:43 pm
Powered by Dreamwidth Studios