[Gllug] Faster maths?

Andy Farnsworth farnsaw at stonedoor.com
Fri Mar 9 12:03:34 UTC 2007


Adrian McMenamin wrote:
> On Fri, March 9, 2007 10:27 am, John Hearns wrote:
>   
>> Adrian McMenamin wrote:
>>     
>>> I have some perl which indexes and dithers a PNG image to a 256 colour
>>> palette.
>>>
>>>       
>> A reply which might not be any use.
>> Which processor and compiler are you using?
>> Are you sure the compiler is making efficient use of parallelism in your
>> processor?
>>
>> I guess though as you are using Perl you can't chop and change the maths
>> library.
>>
>>
>>     
>
> I amjust suing the standard Debian amd64 tools, whatever they may be.
>
> I think it might actually be the slowness of perl hashes that is the issue
> here - I tested out the dithering on a 16 colour palette - which would
> mean making an order of magnitude less calculations than the 256 palette
> (as the number of distances needing to be comapared would fall) - but it
> took around 10 hours to complete - and I can only assume that is because
> it pushed the matches into the lookup hash.
>
> Having said that, I am only now running this test with the 256 colour
> palette and this image, so maybe that will take even longer!
>
> Is hashing in perl really that slow?
>
>   
Hashing in perl has been highly optimized.  I have used hashes on the 
order of a million entries and it has worked extremely quickly (<1 
second for 1000 lookups).  The only real issue is if you start to get a 
very large number of hash collisions, then it may slow down.


Andrew Farnsworth
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list