in reply to Re: Peeling the Peelings
in thread Peeling the Peelings

Rate Peel Get_Proparg Peel 1359/s -- -76% Get_Proparg 5780/s 325% --
Looks like thats a wee bit slower.

-Waswas

Replies are listed 'Best First'.
Re: Re: Re: Peeling the Peelings
by gjb (Vicar) on Jul 02, 2003 at 19:46 UTC

    It's easy to optimize a bit, although it's still 20% slower than Aristotle's version :-(

    my %cache = ('-1' => qr/([^\(\)]+)\)+\Z/); sub peel { my $str = shift; my $level = shift || 0; if (!exists $cache{$level}) { my $opening = '[^\(]+\(' x $level; my $closing = '\)' x $level; $cache{$level} = qr/\A$opening(.+?)$closing\Z/; } $str =~ $cache{$level}; return $1; }
    The benchmark results are:
    Rate Fatvamp gjb bobn Aristotle Fatvamp 21155/s -- -14% -17% -28% gjb 24631/s 16% -- -3% -16% bobn 25523/s 21% 4% -- -13% Aristotle 29497/s 39% 20% 16% --

    Best regards, -gjb-