> Patch to speed synopsis example execution time from 2.6 to 0.8s.

Design flaw indeed. My app does a few other things and was taking nearly 5 seconds, without the Imager hacks. Your technique brings it down to the 0.8s range. This is astonishing! Feels almost instant, except in that third loop, thank you.

> Can't deny you the pleasure to replace third loop yourself, similarly to 1st and 2nd loops.

I barely grasp the original code, scanline is over my head for the time being, can you help an anonymonk out? This seemed logicalish from the third loop variables but didn't do enough, or did too much, not that I even know why:

$illumMap->setscanline(x => $nl, y => $i, pixels => $day_p x ($nl + $o +h));
> Accidentally, that fragment (3d loop) isn't run with DateTime picked for synopsis, btw.

What does that mean? Thanks for your help. It's so much faster 5-6x unbelievable!

Finally, to maximize enjoyment, Ham::Locator transforms latitude and longitude to pixel cooordinates or dots on the Ham::WorldMap:

use Ham::Locator; use Ham::WorldMap; my $lat = 40.712778; my $lon = -74.006111; my $png = 'worldmap.png'; my $map = Ham::WorldMap->new; my $loc = Ham::Locator->new; $loc->set_latlng($lat,$lon); $map->dotAtLocator($loc->latlng2loc, 12, Imager::Color->new(0,255,0)); $map->drawNightRegions(DateTime->now); my ($x, $y) = $map->locatorToXY($loc->latlng2loc); $map->write($png) or die $map->errstr; print qq[Dot drawn at $x,$y on $png\n];

In reply to Re^4: Double the speed of Imager->setpixel by Anonymous Monk
in thread Double the speed of Imager->setpixel by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.