Patch to speed synopsis example execution time from 2.6 to 0.8s. Can't deny you the pleasure to replace third loop yourself, similarly to 1st and 2nd loops. Accidentally, that fragment (3d loop) isn't run with DateTime picked for synopsis, btw.
--- WorldMap.pm.old Fri Jun 17 10:33:43 2016 +++ WorldMap.pm Tue Dec 13 10:27:14 2022 @@ -501,6 +501,7 @@ my $illumMap = Imager->new(ysize => $height, xsize => $width); $illumMap = $illumMap->convert(preset => 'addalpha'); my $day = Imager::Color->new(255, 255, 255, 10); + my $day_p = pack 'C4', 255, 255, 255, 10; my ($i, $j, $oh, $nl, $nh); for ($i = 0; $i < $height; $i++) { @@ -510,12 +511,10 @@ $oh = ($nh - $nl) + 1; if (($nl + $oh) > $width) { - for ($j = $nl; $j < $width; $j++) { - $illumMap->setpixel(x => $j, y => $i, color => $d +ay); - } - for ($j = 0; $j < ((($nl + $oh) - $width) + 1); $j++) + { - $illumMap->setpixel(x => $j, y => $i, color => $d +ay); - } + $illumMap->setscanline(x => $nl, y => $i, + pixels => $day_p x ($width - $nl - 1)); + $illumMap->setscanline(x => 0, y => $i, + pixels => $day_p x ($nl + $oh - $width)); } else { for ($j = $nl; $j < (($nl + $oh) + 1); $j++) { $illumMap->setpixel(x => $j, y => $i, color => $d +ay);
In reply to Re^3: Double the speed of Imager->setpixel
by Anonymous Monk
in thread Double the speed of Imager->setpixel
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |