<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!perl -w
use strict;
use threads;
use Imager;

++$|;
Imager-&gt;preload;

# as a TIFF this file is large, build it from largeish.jpg if it
# doesn't exist
unless (-f "bench/largish.gif") {
  my $im = Imager-&gt;new(file =&gt; "bench/largish.jpg")
    or die "Cannot read bench/largish.jpg:", Imager-&gt;errstr;
  $im-&gt;write(file =&gt; "bench/largish.gif")
    or die "Cannot write bench/largish.gif:", $im-&gt;errstr;
}

my @tests =
  (
   [ "bench/largish.gif", "" ],
   [ "GIF/testimg/scale.gif", "" ],
   [ "GIF/testimg/nocmap.gif", "Image does not have a local or a global color map" ],
  );

my @threads;
my $name = "A";
for my $test (@tests) {
  push @threads,
    threads-&gt;create
      (
       sub  {
	 my ($file, $result, $name) = @_;
	 for (1 .. 100000) {
	   print $name;
	   my $im = Imager-&gt;new(file =&gt; $file);
	   if ($result) {
	     $im and die "Expected error from $file, got image";
	     Imager-&gt;errstr eq $result
	       or die "Expected error '$result', got '",Imager-&gt;errstr, "'"
	   }
	   else {
	     $im or die "Expected image got error '", Imager-&gt;errstr, "'";
	   }
	 }
	 return;
       },
       @$test,
       $name
      );
  ++$name;
}

for my $t (@threads) {
  $t-&gt;join();
}
</pre></body></html>