[Hampshire] problem with Perl/Tk idletasks

Top Page

Reply to this message
Author: Peter Alefounder
Date:  
To: hampshire
Subject: [Hampshire] problem with Perl/Tk idletasks
Is there an expert on Perl/Tk on this list, or can someone point me
towards some forum where there is such an expert, please?

I have a Perl/Tk script which takes data and plots it in graphical
form on a canvas, under the control of various widgets in a separate
control window. One function is a loop which runs through a table of
data, continuously updating the canvas. I noticed that it was
gradually slowing down as it did this.

In order to allow continuous update of the canvas and have the loop
under the control of a button widget, I included an 'update' for the
main window at the end of the loop, thus:

$mw->update;

After adding code to output time data, I discovered that it was this
update that was gradually taking longer to do. The 'idletasks'
command will just update windows without looking at user events such
as button clicks. I separated out updating the canvas from
everything else:

$canvas->idletasks;
$mw->update;

and added more commands to output time data. It is updating the
canvas that is gradually taking longer each iteration of the loop. I
also added code to count the number of changes being made to each
window as the loop runs. This is typical output:

ttest 1, canv 966, control 8, idle-c 0.007278, update 0.000156, rest 0.043368
ttest 2, canv 972, control 8, idle-c 0.007437, update 0.002345, rest 0.039838
ttest 3, canv 977, control 8, idle-c 0.009456, update 0.000136, rest 0.038449
ttest 4, canv 973, control 8, idle-c 0.009024, update 0.002611, rest 0.038897
ttest 5, canv 972, control 8, idle-c 0.009814, update 0.002449, rest 0.038969
ttest 6, canv 983, control 8, idle-c 0.011713, update 0.000135, rest 0.038553
ttest 7, canv 995, control 8, idle-c 0.011649, update 0.002215, rest 0.040011
ttest 8, canv 994, control 8, idle-c 0.013915, update 0.000219, rest 0.038726
ttest 9, canv 986, control 8, idle-c 0.014393, update 0.000157, rest 0.039403
ttest 10, canv 984, control 8, idle-c 0.01484, update 0.000109, rest 0.038947
...
ttest 130, canv 993, control 8, idle-c 0.118537, update 0.000643, rest 0.038524
ttest 131, canv 994, control 8, idle-c 0.116845, update 0.000618, rest 0.039693
ttest 132, canv 987, control 8, idle-c 0.117751, update 0.000646, rest 0.038624
ttest 133, canv 981, control 8, idle-c 0.11894, update 0.000627, rest 0.038515
ttest 134, canv 983, control 8, idle-c 0.119837, update 0.000126, rest 0.038105
ttest 135, canv 985, control 8, idle-c 0.12229, update 0.000145, rest 0.039671
ttest 136, canv 980, control 8, idle-c 0.120933, update 0.000137, rest 0.039311
ttest 137, canv 980, control 8, idle-c 0.123748, update 0.000143, rest 0.038038
ttest 138, canv 989, control 8, idle-c 0.122451, update 0.000137, rest 0.038729
ttest 139, canv 997, control 8, idle-c 0.124475, update 0.000143, rest 0.040466
ttest 140, canv 992, control 8, idle-c 0.124461, update 0.003396, rest 0.039014

ttest:   loop number
canv:    number of changes to the canvas, mainly createRectangle
control: number of changer to the control window
idle-c:  time taken by $canvas->idletasks;
update:  time taken by $mw->update;
rest:    time taken by the rest of the loop


It is clear that the time taken by $canvas->idletasks fluctuates,
but is on a rising trend. The number of changes to the canvas is
remaining fairly steady.

Any ideas? I would be grateful for advice on how to fix this.

Peter Alefounder.

--
Please post to: Hampshire@???
Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire
LUG URL: http://www.hantslug.org.uk
--------------------------------------------------------------