[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Duff's Device in Perl



On Mon, Mar 27, 2000 at 10:51:41PM +0000, David L. Nicol wrote:

(Oops! Sorry for the late reply. This seems to have missed my notice.)

> unrolling the whole thing and evalling it makes it about 10X slower
> 
>     eval '$to = (substr $from, $i++, 1);' x length $from;

That's not surprising, since you're invoking the compiler to
generate branch-light code. Your code, when it runs, will run
very quickly; but preparing it is slow (and happens at run
time). The Device is an efficient way to reduce branches, at
run time.

> "With diligence it is possible to make anything run slowly." -- Duff

:-)

(Reminds me of networking logging code that makes DNS lookups on
every entry)

-- 
believing is seeing
gaal@forum2.org
http://www.forum2.org/gaal/

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe