GigaRoc has asked for the wisdom of the Perl Monks concerning the following question:

I wrote perl program with a GTK frontend to search IIS weblogs and display the output on a GUI, And it works, except it's quite slow, almost none responsive, to scroll threw the list once it displays. Here's the deceleration
our $table = Gtk2::SimpleList->new_from_treeview ( $gui->get_widget ('Table'), 'Date' => 'markup', 'Time' => 'markup', 'IP Address' => 'markup', 'Status' => 'markup', 'WebServer' => 'markup', 'Action' => 'markup', 'URL1' => 'markup', 'URL2' => 'markup', 'Cookie Info' => 'markup'); $table->get_selection->set_mode ('multiple'); $table->get_selection->unselect_all; $table->set_reorderable (TRUE); map { $_->set_resizable (TRUE) } $table->get_columns;
and here is where i populate it
for $temp (@rArray){ my $pre; my $post = "</span>"; my ($a1,$b1,$c1,$d1,$e1,$f1,$g1,$h1) = split(/;;/,$tem +p); if ($d1 eq "200"){ $pre = "<span foreground=\"#CCCC00\">"; } if ($d1 eq "300"){ $pre = "<span foreground=\"#00FF99\">"; } if ($d1 eq "400"){ $pre = "<span foreground=\"#900000\">"; } if ($d1 eq "500"){ $pre = "<span foreground=\"#6600FF\">"; } $a1 = $pre.$a1.$post; $a1 =~ s/&/&amp;/g; $b1 = $pre.$b1.$post; $b1 =~ s/&/&amp;/g; $c1 = $pre.$c1.$post; $c1 =~ s/&/&amp;/g; $d1 = $pre.$d1.$post; $d1 =~ s/&/&amp;/g; $e1 = $pre.$e1.$post; $e1 =~ s/&/&amp;/g; $f1 = $pre.$f1.$post; $f1 =~ s/&/&amp;/g; $g1 = $pre.$g1.$post; $g1 =~ s/&/&amp;/g; $h1 = $pre.$h1.$post; $h1 =~ s/&/&amp;/g; push @{$table->{data}},[$a1,$b1,$c1,$d1,$e1,$f1,$g1,$h +1]; }
Am i doing something wrong? Does anyone have any suggestions on how to speed up the scrolling?

Replies are listed 'Best First'.
Re: GTK2::SimpleList really slow
by zentara (Cardinal) on Jun 29, 2011 at 14:52 UTC
    Am i doing something wrong? Does anyone have any suggestions on how to speed up the scrolling?

    You don't have a complete running example, but those regexes look like a likely cause of a slowdown. Below is a simple example of how to scroll the list.

    #!/usr/bin/perl use warnings; use strict; use Gtk2 qw/-init/; use Gtk2::SimpleList; my $count = 0; my $win = Gtk2::Window->new; $win->signal_connect( 'destroy' => sub{exit} ); $win->set_default_size(300,200); $win->set_position('center'); my $sw = Gtk2::ScrolledWindow->new (undef, undef); $sw->set_policy ('automatic', 'automatic'); my $ha1 = $sw->get_vadjustment; my $list = Gtk2::SimpleList->new('test' => 'int',); $sw->add($list); $win->add($sw); $win->show_all; Glib::Timeout->add(500, \&update, $list); Gtk2->main; sub update{ my $list = shift; push @{$list->{data}},rand $count++; # bad hack method # $list->scroll_to_point(0,1000); # muppet's suggestion for better scrolling # find the path of the last row in the model. my $path = Gtk2::TreePath->new_from_indices (scalar (@{ $list->{data} }) - 1); # the scalar-of-array is actually just a tie() wrapper for # n_rows = $list->get_model->iter_n_children (undef); # now scroll to that row. let all of the other parameters # default, because we don't need them. $list->scroll_to_cell ($path); return 1; }

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh