[squeak-dev] Re: quick handling of graphics files
juan at jvuletich.org
Wed Apr 14 20:08:32 UTC 2010
Ross Boylan wrote:
> On Tue, 2010-04-13 at 21:05 -0700, Andreas Raab wrote:
>> Hi Ross -
>> Profiling is your friend. In most cases, 95% of the time are spent in 5%
>> of the code. From what you're saying below it sounds that you're using
>> one of the 'special' PNG modes (black and white, or gray-scale) that
>> probably have seen less attention for optimization than others. Any
>> chance you can post a sample image for profiling it?
> I've attached a test image, which takes about 30 seconds for me. It is
> a 1 bit depth image. Not sure if the attachment will make it
Profiling is indeed your friend.
There is some serious inefficiency there. Quickly hacking this (warning:
will only work for 1bpp):
"Handle non-interlaced grayscale color mode (colorType = 0)"
| word base ii |
base := y * form width//32 +1.
0 to: thisScanline size-1 // 4 do: [ :i |
ii := i * 4.
(thisScanline at: ii+1) << 24 bitOr: (
(thisScanline at: ii+2) << 16 bitOr: (
(thisScanline at: ii+3) << 8 bitOr: (
(thisScanline at: ii+4)))).
form bits at: base + i put: word ].
gives over 30x speed increase (from 10 seconds down to 310 mSec) on my
system. This is not a solution, just some food for thought.
More information about the Squeak-dev