note
Anonymous Monk
<p> How many tk objects are you keeping in memory?
<p> Are you using some kind of a <b>virtual</b> tree control, one that doesn't keep all objects in memory?
<p> On my machine, Scrolled doesn't like more than ~1300 buttons, I don't care why <readmore><c> #!/usr/bin/perl --
use strict;
use warnings;
use Tk;
Main( @ARGV );
exit( 0 );
sub Main {
gogogo( shift || 6_200 );
}
sub gogogo {
my( $max ) = @_;
my $mw = tkinit;
for my $ix ( 1 .. 3 ){
my $button = $mw->Button( -text => "Make $max" )->pack;
my $frame = $mw->Scrolled('Frame')->pack(qw/ -expand 1 -fill both /);
$button->configure( -command => [ \&makesome, $frame , $max ] );
}
$mw->MainLoop;
}
sub makesome {
my( $frame , $max ) = @_;
$frame->Busy;
my $button = $Tk::event->W ;
$button->configure( qw/ -state disabled /);
$button->update;
$frame->update;
my $time = time;
print "$frame ( $max ) $time\n";
for my $ix( 0 .. $max ){
my $button = $frame->Button( -text => $ix )->pack;
$button->configure( qw/ -state disabled /);
}
$frame->update;
$frame->Unbusy;
my $time2 = time;
print "$frame ( $max ) $time2 #### $time2 - $time = @{[ $time2 - $time ]}\n";
return;
}</c></readmore>
<P> But FWIW, <b>Firefox</b> doesn't like a lot of buttons either, and frankly, that many actual button objects is too many -- same as displaying 1000 search results, for human not to go insane, you have to [dict://pageinate]
<p> Devel::NYTprof to find bottle necks, code review to find thinko-s, and prototyping to figure out limits, try out cheap fixes... code review suspect widgets ... repeat
<p> [id://784055|Why so slow when using Perl/Tk?], [id://318089|Tk::Table too slow. Alternatives ?], [id://907592|Why is wxPerl slower than Win32GUI?], [id://426089|Comparing Tcl::Tk and perlTk WRT speed],
<p> [href://http://wiki.tcl.tk/10923|Virtual grid widget], [href://http://wiki.tcl.tk/348|Tcl Performance] / [href://http://wiki.tcl.tk/393|Tk Performance]
<p> [mod://Wx::Perl::ListView]/[mod://Wx::Perl::ListView::SimpleModel]
1048489
1048489
3