in reply to Why is Tk::Animation so slow?

Hi,

Profile it? NYTProf? zinc

Replies are listed 'Best First'.
Re^2: Why is Tk::Animation so slow?
by Anonymous Monk on Dec 22, 2019 at 04:06 UTC
    Here's the data on 2 animations with similar filesize, parts (frames), colortable, and delay but I still can't see why the slow one spends so much time in Tk::image::new:
     my $obj = $widget->Tk::image('create',$leaf,@_); # the slowest line of code
    

    GIF1 3.9M
    66 parts
    Tk::Animation took 3.60994100570679 seconds for 4096259 bytes
    
    Stmts	Exclusive
    	Time 		Source File
    490	3.29s	line	Tk/Image.pm
    659	812ms	line	Tk.pm
    102086	274ms	line	Image/Info/GIF.pm
    
    # spent 3.29s (2.17ms+3.29) within Tk::Image::new which was called 68 times, avg 48.4ms/call: 
    # 67 times (2.15ms+3.29s) by Tk::Animation::new at line 37 of Tk/Animation.pm, avg 49.1ms/call 
    # once (28µs+2.33ms) by Tk::Animation::new at line 26 of Tk/Animation.pm
    
    # spent 121ms (57.5+63.4) within Image::Info::GIF::my_read which was called 16632 times, avg 7µs/call:
    # 16094 times (56.0ms+63.3ms) by Image::Info::GIF::seek_data_blocks at line 50, avg 7µs/call
    #   203 times (582µs+47µs) by Image::Info::GIF::read_data_blocks at line 41, avg 3µs/call
    #   134 times (375µs+50µs) by Image::Info::GIF::process_file at line 110, avg 3µs/call
    #    67 times (166µs+13µs) by Image::Info::GIF::process_file at line 152, avg 3µs/call
    #    66 times (179µs+20µs) by Image::Info::GIF::process_file at line 143, avg 3µs/call
    #    66 times (164µs+10µs) by Image::Info::GIF::process_file at line 126, avg 3µs/call
    #        once (11µs+9µs) by Image::Info::GIF::process_file at line 59
    #        once (1µs+1µs) by Image::Info::GIF::process_file at line 99
    
    BackgroundColor  0
    ColorResolution  8
    ColorTableSize 	 256
    Delay 	         0.08
    DisposalMethod 	 1
    GIF_Loop 	 forever
    GIF_Version 	 89a
    GlobalColorTableFlag 	 1
    ScreenHeight 	 360
    ScreenWidth 	 300
    SortedColors 	 0
    XPosition 	 0
    YPosition 	 0
    color_type 	 Indexed-RGB
    file_ext 	 gif
    file_media_type  image/gif
    height 	         360
    resolution 	 1/1
    width 	         300
    

    GIF2 4.9M
    60 parts
    Tk::Animation took 33.700756072998 seconds for 5088374 bytes 
    
    Stmts	Exclusive
    	Time 		Source File
    448	33.4s	line	Tk/Image.pm
    645	738ms	line	Tk.pm
    124973	254ms	line	Image/Info/GIF.pm
    	
    # spent 33.4s (1.58ms+33.4) within Tk::Image::new which was called 62 times, avg 539ms/call:
    # 61 times (1.54ms+33.4s) by Tk::Animation::new at line 37 of Tk/Animation.pm, avg 548ms/call
    #     once (39µs+6.58ms) by Tk::Animation::new at line 26 of Tk/Animation.pm
    
    # spent 112ms (54.6+57.9) within Image::Info::GIF::my_read which was called 20478 times, avg 5µs/call:
    # 19957 times (53.3ms+57.7ms) by Image::Info::GIF::seek_data_blocks at line 50, avg 6µs/call
    #   214 times (539µs+57µs) by Image::Info::GIF::read_data_blocks at line 41, avg 3µs/call
    #   123 times (284µs+40µs) by Image::Info::GIF::process_file at line 110, avg 3µs/call
    #    62 times (117µs+14µs) by Image::Info::GIF::process_file at line 152, avg 2µs/call
    #    60 times (167µs+6µs) by Image::Info::GIF::process_file at line 126, avg 3µs/call
    #    60 times (130µs+15µs) by Image::Info::GIF::process_file at line 143, avg 2µs/call
    #        once (16µs+16µs) by Image::Info::GIF::process_file at line 59
    #        once (5µs+2µs) by Image::Info::GIF::process_file at line 99
    
    BackgroundColor.  0
    ColorResolution   8
    ColorTableSize 	  256
    Delay 	          0.03
    DisposalMethod 	  1
    GIF_Loop 	  forever
    GIF_Version 	  89a
    GlobalColorTableFlag 	 1
    ScreenHeight 	  480
    ScreenWidth 	  480
    SortedColors 	  0
    TransparencyIndex 255
    XPosition 	  0
    YPosition 	  0
    color_type 	  Indexed-RGB
    file_ext 	  gif
    file_media_type   image/gif
    height 	          480
    resolution 	  1/1
    width 	          480
    

    Thank you

      but I still can't see why the slow one spends so much time in Tk::image::new:

      Look deeper ;)