"Fossies" - the Fresh Open Source Software Archive

Member "Tk-804.036/examples/after_leak" (15 Nov 2013, 675 Bytes) of package /linux/misc/Tk-804.036.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/local/bin/perl -w
    2 
    3 use Tk;
    4 use Devel::Leak;
    5 
    6 $count = 0;
    7 
    8 sub flash_widget
    9 {
   10  my($w, $option, $val1, $val2, $interval) = @_;
   11  $w->configure($option => $val1);
   12  $w->after($interval, [\&flash_widget, $w, $option, $val2, $val1, $interval] );
   13  $count++;
   14 } # end flash_widget
   15 
   16 $mw = MainWindow->new;
   17 $b = $mw->Button(-text => 'Flash', -bg => 'azure');
   18 $b->pack;
   19 flash_widget $b, -background, 'azure', 'yellow', 40;
   20 $mw->update;
   21 print STDERR "Before ",$start = Devel::Leak::NoteSV($hook),"\n";
   22 $count = 0;
   23 #MainLoop;
   24 while ($count < 100)
   25  {
   26   Tk::DoOneEvent(0);
   27  }
   28 print STDERR "After  ",$end = Devel::Leak::CheckSV($hook),"\n";
   29 
   30 print "Average ",($end-$start)/$count,"\n";