For Programmers: Free Programming Magazines  


Home > Archive > PERL POE > May 2007 > POE & Tk excessive CPU usage?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author POE & Tk excessive CPU usage?
Craig Votava

2007-04-27, 7:15 pm

Folks-

When I use POE and Tk together, I see the
process using up a constant 50% of my CPU,
even when there's nothing going on.

Am I doing something wrong, or is there a
good explanation for this? Is there any
way to reduce this?

Attached is a small test program.

Thanks

-Craig

#!/usr/bin/perl

use warnings;
use strict;

use Tk;
use POE;

POE::Session->create
( inline_states =>
{ _start => \&ui_start,
ev_count => sub { $_[HEAP]->{counter}++; },
ev_clear => sub { $_[HEAP]->{counter} = 0; },
}
);

$poe_kernel->run();
exit 0;

sub ui_start {
my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ];

$poe_main_window->Label( -text => "Counter" )->pack;

$heap->{counter} = 0;
$heap->{counter_widget} =
$poe_main_window->Label( -textvariable => \$heap->{counter} )-
>pack;


$poe_main_window->Button
( -text => "Count",
-command => $session->postback("ev_count")
)->pack;

$poe_main_window->Button
( -text => "Clear",
-command => $session->postback("ev_clear")
)->pack;
}
Craig Votava

2007-05-02, 7:17 pm

Folks-

Anybody have any thoughts on this? I haven't heard
a whisper yet. Do others see the same thing?

Thanks

-Craig

On Apr 27, 2007, at 11:15 AM, Craig Votava wrote:

> Folks-
>
> When I use POE and Tk together, I see the
> process using up a constant 50% of my CPU,
> even when there's nothing going on.
>
> Am I doing something wrong, or is there a
> good explanation for this? Is there any
> way to reduce this?
>
> Attached is a small test program.
>
> Thanks
>
> -Craig
>
> #!/usr/bin/perl
>
> use warnings;
> use strict;
>
> use Tk;
> use POE;
>
> POE::Session->create
> ( inline_states =>
> { _start => \&ui_start,
> ev_count => sub { $_[HEAP]->{counter}++; },
> ev_clear => sub { $_[HEAP]->{counter} = 0; },
> }
> );
>
> $poe_kernel->run();
> exit 0;
>
> sub ui_start {
> my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ];
>
> $poe_main_window->Label( -text => "Counter" )->pack;
>
> $heap->{counter} = 0;
> $heap->{counter_widget} =
> $poe_main_window->Label( -textvariable => \$heap->{counter} )-
>
> $poe_main_window->Button
> ( -text => "Count",
> -command => $session->postback("ev_count")
> )->pack;
>
> $poe_main_window->Button
> ( -text => "Clear",
> -command => $session->postback("ev_clear")
> )->pack;
> }


Mark Swayne

2007-05-02, 7:17 pm

I see the same thing on my system, using:
POE 0.9989
Tk 804.27
Perl 5.8.8 (ActivePerl build 819)

The process is eating a whole CPU. Since I have a dual processor setup,
the script is pegged at 50% CPU utilization.

--Mark Swayne


Craig Votava wrote:
> Folks-
>
> When I use POE and Tk together, I see the
> process using up a constant 50% of my CPU,
> even when there's nothing going on.
>
> Am I doing something wrong, or is there a
> good explanation for this? Is there any
> way to reduce this?
>
> Attached is a small test program.
>
> Thanks
>
> -Craig
>
> #!/usr/bin/perl
>
> use warnings;
> use strict;
>
> use Tk;
> use POE;
>
> POE::Session->create
> ( inline_states =>
> { _start => \&ui_start,
> ev_count => sub { $_[HEAP]->{counter}++; },
> ev_clear => sub { $_[HEAP]->{counter} = 0; },
> }
> );
>
> $poe_kernel->run();
> exit 0;
>
> sub ui_start {
> my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ];
>
> $poe_main_window->Label( -text => "Counter" )->pack;
>
> $heap->{counter} = 0;
> $heap->{counter_widget} =
> $poe_main_window->Label( -textvariable => \$heap->{counter}
> )->pack;
>
> $poe_main_window->Button
> ( -text => "Count",
> -command => $session->postback("ev_count")
> )->pack;
>
> $poe_main_window->Button
> ( -text => "Clear",
> -command => $session->postback("ev_clear")
> )->pack;
> }
>
>


Robert Landrum

2007-05-02, 7:17 pm

Craig Votava wrote:[color=darkred]

truss (sun) or strace (linux) will tell you what system commands it's
running, which would help you figure out what's causing the problem.

Rob
Buttface

2007-05-04, 4:02 pm

http://Britney-Spears-jerking.info/...hp?movie=148803
Adedjotard53

2007-05-06, 8:23 am

http://Johnny-Depp-lesbian-strip.or...hp?movie=148803
Dapebun42

2007-05-12, 9:11 am

Cute blonde with REALLY big titties!
http://trully-bigtits.info/play.asp?bigtits218571
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com