Performance problems with "photo copy -to"

Liste des GroupesRevenir à cl tcl 
Sujet : Performance problems with "photo copy -to"
De : obermeier (at) *nospam* poSoft.de (Paul Obermeier)
Groupes : comp.lang.tcl
Date : 07. Nov 2024, 21:43:36
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vgj8r1$2poj6$1@dont-email.me>
User-Agent : Mozilla Thunderbird
I have a simple tiling procedure and noticed a slowdown when using large images,
i.e. when doing lots of copies.
I noticed the following behaviours (both on Windows and Linux):
1. The time for copying does not grow linearly, as expected, but gets larger the more copies are involved.
2. The copy time of Tcl/Tk 9 is nearly twice the time as when using Tcl/Tk 8.6.15 or the combination
    Tcl 8.7/Tk 9. So this performance degradation does not seem to stem from Tk9, but from Tcl9. Strange!
Can anybody confirm my measurements?
Thanks,
Paul
Using Tcl 8.6.15, Tk 8.6.15
Time for  100 copies:  0.69 seconds (  6 milliseconds / copy)
Time for  400 copies: 10.26 seconds ( 25 milliseconds / copy)
Time for  900 copies: 51.12 seconds ( 56 milliseconds / copy)
  Using Tcl 8.7b1, Tk 9.0.0
Time for  100 copies:  0.70 seconds (  7 milliseconds / copy)
Time for  400 copies: 10.22 seconds ( 25 milliseconds / copy)
Time for  900 copies: 51.35 seconds ( 57 milliseconds / copy)
  Using Tcl 9.0.0, Tk 9.0.0
Time for  100 copies:  1.28 seconds ( 12 milliseconds / copy)
Time for  400 copies: 19.45 seconds ( 48 milliseconds / copy)
Time for  900 copies: 98.16 seconds (109 milliseconds / copy)
package require Tk
proc Tile { phImg xRepeat yRepeat } {
     set startTime [clock milliseconds]
     set w [image width  $phImg]
     set h [image height $phImg]
     set w2 [expr {$w * $xRepeat}]
     set h2 [expr {$h * $yRepeat}]
     set tileImg [image create photo -width $w2 -height $h2]
     for { set x 0 } { $x < $xRepeat } { incr x } {
         for { set y 0 } { $y < $yRepeat } { incr y } {
             $tileImg copy $phImg -to [expr {$x*$w}] [expr {$y*$h}]
         }
     }
     set endTime [clock milliseconds]
     puts [format "Time for %4d copies: %5.2f seconds (%3d milliseconds / copy)" \
          [expr {$xRepeat * $yRepeat}] \
          [expr { ($endTime - $startTime) / 1000.0 }] \
          [expr { ($endTime - $startTime) / ($xRepeat * $yRepeat) }]]
     return $tileImg
}
set srcImg [image create photo -width 500 -height 500]
puts "Using Tcl [info patch], Tk [package version Tk]"
Tile $srcImg 10 10
Tile $srcImg 20 20
Tile $srcImg 30 30
exit

Date Sujet#  Auteur
7 Nov 24 * Performance problems with "photo copy -to"9Paul Obermeier
7 Nov 24 +* Re: Performance problems with "photo copy -to"2elns
7 Nov 24 i`- Re: Performance problems with "photo copy -to"1elns
8 Nov 24 +* Re: Performance problems with "photo copy -to"2greg
8 Nov 24 i`- Re: Performance problems with "photo copy -to"1greg
8 Nov 24 +- Re: Performance problems with "photo copy -to"1saito
8 Nov 24 `* Re: Performance problems with "photo copy -to"3Paul Obermeier
9 Nov 24  +- Re: Performance problems with "photo copy -to"1greg
10 Nov 24  `- Re: Performance problems with "photo copy -to"1Harald Oehlmann

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal