Economizei mais performance:
sub is_ordered {
my $a = shift;
my $numta = 1;
for ( my $i = 1 ; $i < @{$a} ; $i++ ) {
$numta = 0 if ( $a->[ $i - 1 ] > $a->[$i] && $numta == 1);
}
return 0 if !$numta;
return 1 if $numta;
return undef if (!$numta || $numta); # muito importante
}
2011/5/19 Alexei Znamensky <[email protected]>
> já fiz um script de testar bogosort pra voce
>
> https://github.com/russoz/perltests/blob/master/test-sort-bogosort.pl
>
>
> 2011/5/19 Renato Santos <[email protected]>
>
>> Haha
>> qual seria o titulo? como economizar performance em perl ?
>> =D
>>
>>
>> 2011/5/19 Wesley Seidel <[email protected]>
>>
>>> Ae Renato, já é material pra um post em um blog, se vc tiver... ;)
>>>
>>> 2011/5/19 Renato Santos <[email protected]>
>>>
>>>> %CPU %MEM TIME+ COMMAND
>>>> 100 0.1 208:28.98 perl /tmp/xxx.pl2
>>>>
>>>> 2011/5/19 Eden Cardim <[email protected]>
>>>>
>>>>> >>>>> "Wesley" == Wesley Seidel <[email protected]> writes:
>>>>>
>>>>> Wesley> ahahaha Se levou tudo isso com um quicksort, imagine o tempo
>>>>> Wesley> pra fazer essa dança com um bubblesort. :D
>>>>>
>>>>> Confere aí: http://bit.ly/iCAE1x
>>>>>
>>>>> --
>>>>> Eden Cardim Need help with your Catalyst or DBIx::Class
>>>>> project?
>>>>> Code Monkey http://www.shadowcat.co.uk/catalyst/
>>>>> Shadowcat Systems Ltd. Want a managed development or deployment
>>>>> platform?
>>>>> http://blog.edencardim.com/
>>>>> http://www.shadowcat.co.uk/servers/
>>>>> =begin disclaimer
>>>>> Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
>>>>> SaoPaulo-pm mailing list: [email protected]
>>>>> L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
>>>>> =end disclaimer
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Renato Santos
>>>> http://www.renatocron.com/blog/
>>>>
>>>> =begin disclaimer
>>>> Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
>>>> SaoPaulo-pm mailing list: [email protected]
>>>> L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
>>>> =end disclaimer
>>>>
>>>>
>>>
>>>
>>> --
>>> Wesley Seidel Carvalho
>>> 11-6671-6118
>>> 11-8169-1163
>>> http://twitter.com/wseidel
>>>
>>>
>>>
>>> =begin disclaimer
>>> Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
>>> SaoPaulo-pm mailing list: [email protected]
>>> L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
>>> =end disclaimer
>>>
>>>
>>
>>
>> --
>> Renato Santos
>> http://www.renatocron.com/blog/
>>
>> =begin disclaimer
>> Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
>> SaoPaulo-pm mailing list: [email protected]
>> L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
>> =end disclaimer
>>
>>
>
>
> --
> Alexei "RUSSOZ" Znamensky
> [russoz_gmail_com] [russoz.wordpress.com] [www.flickr.com/photos/alexeiz]
> [https://github.com/russoz]
> Only love / Can bring the rain / That makes you yearn to the sky
>
>
> =begin disclaimer
> Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
> SaoPaulo-pm mailing list: [email protected]
> L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
> =end disclaimer
>
>
--
Renato Santos
http://www.renatocron.com/blog/
=begin disclaimer
Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
SaoPaulo-pm mailing list: [email protected]
L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
=end disclaimer