It appears that Tcl::Tk is faster than perl/Tk
Tcl::Tk must be at least version 0.86

Consider following "stress-test" code, at first perlTk:

use Tk; my $mw = tkinit; my $tw = $mw->Scrolled('Text')->pack; my $t0=time; for my $stresser ('a'..'zzz') { $tw->windowCreate('end',-window=>$tw->Button(-text=>$stresser)); if ($stresser =~ /z$/) { $tw->insert('end',"\n") ; $tw->see('end'); #$tw->update; } } my $t1=time; print STDERR "time=".($t1-$t0)."\n"; MainLoop;
It does simple but numerous action: it inserts a number similar buttons into Text widget. On my slow PC it reports execution time of 52sec.
It appears that similar Tcl::Tk code executes almost twice as fast, 28sec:
use Tcl::Tk qw(:perlTk); my $mw = tkinit; my $tw = $mw->Scrolled('Text')->pack; my $t0=time; for my $stresser ('a'..'zzz') { $tw->windowCreate('end',-window=>$tw->Button(-text=>$stresser)); if ($stresser =~ /z$/) { $tw->insert('end',"\n") ; $tw->seeEnd; #$tw->update; } } my $t1=time; print STDERR "time=".($t1-$t0)."\n"; MainLoop;
Additionally, Tcl::Tk has special consideration of faster invocation of widgets methods, when no preprocessing needed; this approach saves another 20%, so finishing in 23sec:
use Tcl::Tk qw(:perlTk); my $mw = tkinit; my $tw = $mw->Scrolled('Text')->pack; my $t0=time; for my $stresser ('a'..'zzz') { $tw->_windowCreate('end',-window=>$tw->_Button(-text=>$stresser)); if ($stresser =~ /z$/) { $tw->_insert('end',"\n") ; $tw->_seeEnd; #$tw->update; } } my $t1=time; print STDERR "time=".($t1-$t0)."\n"; MainLoop;
In order to gain better execution speed, it is possible to compile Tcl/Tk binaries into Tcl::Tk module and to use common with Perl memory allocator, but this could be subject for deeper meditation.

My PerlTk installation is that one coming with ActiveState's build of both Linux and Windows perls, Tcl::Tk I built for myself...

Memory consumption is on Tcl::Tk side also better.

PS. why this stupid dog did not used Benchmark? Okay, if this is essential, I'll do deeper investigation in reply to first person who interested in that


In reply to Comparing Tcl::Tk and perlTk WRT speed by Courage

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.