Skip Menu |

This queue is for tickets about the Imager CPAN distribution.

Report information
The Basics
Id: 64785
Status: resolved
Priority: 0/
Queue: Imager

People
Owner: Nobody in particular
Requestors: tokuhirom [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: GIF encoding is very slower on Imager 0.78+
Date: Sat, 15 Jan 2011 07:23:52 +0900
To: bug-Imager [...] rt.cpan.org
From: Tokuhiro Matsuno <tokuhirom [...] gmail.com>
In my environment, Imager 0.78+'s GIF encoding is very slow. This is benchmark code. -- 8< ---------------------------------------------------------------------------------------- 8< ----------------------------- #!/usr/bin/perl use strict; use warnings; use utf8; use Benchmark ':all'; use Config; use lib; # cpanm --reinstall -nv -l lib-0.75 http://search.cpan.org/CPAN/authors/id/T/TO/TONYC/Imager-0.75.tar.gz # cpanm --reinstall -nv -l lib-0.75 http://search.cpan.org/CPAN/authors/id/T/TO/TONYC/Imager-0.78.tar.gz my $version = shift or die "Usage: $0 version[ benchmark-times]\n"; lib->import("lib-$version/lib/perl5/"); require Imager; print "$^O perl $]\n"; print "Imager: $Imager::VERSION\n"; print "Imager::File::GIF: $Imager::File::GIF::VERSION\n" if $Imager::File::GIF::VERSION; print "\n"; my $n = shift || 1000; timethis($n, sub { my $img = Imager->new(xsize => 128, ysize => 128) or die; $img->write(data => \my $out, type => 'gif'); }); -- 8< ---------------------------------------------------------------------------------------- 8< ----------------------------- This is a benchmark result. -- 8< ---------------------------------------------------------------------------------------- 8< ----------------------------- % perl benchmark.pl 0.75 100 darwin perl 5.012002 Imager: 0.75 timethis 100: 0 wallclock secs ( 0.20 usr + 0.00 sys = 0.20 CPU) @ 500.00/s (n=100) (warning: too few iterations for a reliable count) % perl benchmark.pl 0.78 100 darwin perl 5.012002 Imager: 0.78 timethis 100: 16 wallclock secs ( 9.49 usr + 0.14 sys = 9.63 CPU) @ 10.38/s (n=100) -- 8< ---------------------------------------------------------------------------------------- 8< -----------------------------
On Fri Jan 14 17:24:07 2011, tokuhirom@gmail.com wrote: Show quoted text
Presumably these were actually installed to separate directories. Show quoted text
> % perl benchmark.pl 0.75 100 > darwin perl 5.012002 > Imager: 0.75 > > timethis 100: 0 wallclock secs ( 0.20 usr + 0.00 sys = 0.20 CPU) @ > 500.00/s (n=100) > (warning: too few iterations for a reliable count) > % perl benchmark.pl 0.78 100 > darwin perl 5.012002 > Imager: 0.78 > > timethis 100: 16 wallclock secs ( 9.49 usr + 0.14 sys = 9.63 CPU) @ > 10.38/s (n=100)
Thanks, I've reproduced this, it looks like it happened with the move to a separate module in 0.78: Imager: 0.77 timethis for 10: 10 wallclock secs (10.41 usr + 0.00 sys = 10.41 CPU) @ 888.28/s (n=9247) Imager: 0.78 timethis for 10: 11 wallclock secs (10.45 usr + 0.00 sys = 10.45 CPU) @ 19.71/s (n=206) Tony
On Fri Jan 14 17:24:07 2011, tokuhirom@gmail.com wrote: Show quoted text
> In my environment, Imager 0.78+'s GIF encoding is very slow.
The cause is a change in which algorithm is used to build the palette for the GIF file. In 0.77 and earlier, the mediancut algorithm is used. In 0.78 and later the "addi" algorithm is used. As a workaround you can supply: make_colors => "mediancut" to the write call. Tony
On Fri Jan 14 17:24:07 2011, tokuhirom@gmail.com wrote: Show quoted text
> In my environment, Imager 0.78+'s GIF encoding is very slow.
This is fixed in Imager 0.80. The default for make_colors for both GIF output and to_paletted() has beedn changed to "mediancut". Thanks for reporting this. Tony