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

Re: [MacPerl-Toolbox] QuickDraw and MacWindows



See below:
----- Original Message -----
From: "Alan Fry" <ajf@afco.demon.co.uk>
To: "MacPerl Toolbox" <macperl-toolbox@macperl.org>
Sent: Wednesday, June 28, 2000 5:58 AM
Subject: Re: [MacPerl-Toolbox] QuickDraw and MacWindows


> At 6:43 pm -0400 27/06/00, Quentin Smith wrote:
>
> >I think my mailer messed up, as those typos were not there. I can assure
> >you, with the modifications I made, it works fine. Here's a complete
version
> >of the EasyWindow module with my modifications:
>
> My local dial-up connection here in the middle of nowhere degenerates
> into two tin cans and a piece of string, so maybe that is where the
> problem arose.
>
> Sorry, I misunderstood your intention -- in particular the 'sub

> $draw }' line. Sure, that works fine. I think we're in TMTOWTDI
> country now.
>
> However I suspect your version suffers from the same drawback as my
> original version that the eval() gets called every update; because
> when the subroutine &{$draw} is called it in turn calls the eval() in
> '$draw = eval "sub {$str}"'.
What happens is something similar to this:
$str = "print 'test'";
$draw = eval "sub {$str}";
#$draw = eval "sub {print 'test'}";
#$draw = sub {print 'test'};
#$draw = anonymous subroutine reference to print 'test'
foreach $i (1..100) {
&{$draw};
# basically it is executing print 'test', which has been compiled up
# above at the eval.
}
>
> However, does it really matter? I simply don't know what the
> penalties in terms of speed or memory might be in repeatedly running
> an eval(). One has a feeling there probably is a price to pay but I
> have no idea how to measure the effect.
I have hacked up a simple script that tests the speed differences. It does
the command 5*5*5*5.
Here are the results:

Benchmark: timing 100000 iterations of Eval Each Time, Eval Once...
Eval Each Time: 28 secs (27.65 usr  0.00 sys = 27.65 cpu)
Eval Once:  1 secs ( 0.83 usr  0.00 sys =  0.83 cpu)

This was with Benchmark.pm, with this script:
use Benchmark;

$test1 = "5*5*5*5;";
$test2 = eval "sub { $test1 }";
timethese(100000, {
 'Eval Once'      => sub { &{ $test2 } },
 'Eval Each Time' => sub { eval $test1; },
});

>
> Thanks very much for your contribution and interest.
>
> Alan Fry
>
> OT re mailer for interest's sake. The errors are still there:

Stupid mailer. That's what I get for using a Microsoft Product :) I swear
that it was correct when I typed it. And it was correct when I sent it
again. But my sent mail folder has the incorrect version.

>
> At 6:43 pm -0400 27/06/00, Quentin Smith wrote:
> >Here's what my previous message said according to my mailer:
> >Hi-
> >I modified my copy of EasyWindow as Kevin Reid suggested. Here is what I
> >did:
> >In the subroutine DRAWING, change $draw = $str; into $draw = eval "sub
> >  $str }";
> >In the subroutine WINDOW, where the redraw hook is defined, change
> >val( $draw ) into &{ $draw }
>
> ==== Want to unsubscribe from this list?
> ==== Send mail with body "unsubscribe" to
macperl-toolbox-request@macperl.org
>


==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-toolbox-request@macperl.org