From: Timothy Hunter Date: 2005-08-30T08:41:23+09:00 Subject: Re: rmagick question Joe Van Dyk wrote: >>Doing a 10000x10 pixel image (only 10 pixels high for unit testing >>purposes), I could process: >> >>13k pixels/second with the bitshifting approach (and 16 bit IM) >>13k pixels/second with the array lookup approach (and 16 bit IM) >>21k pixels/second with 256 bit IM. >> >>I also found that building up an array of colors for one row and then >>doing a @image.import_pixels had no speed improvements and the code >>was uglier. > > > Hm... I don't think that those pixels/second numbers are correct. I > was doing the timings inside a Benchmark.measure { ... } block and > perhaps that makes things slower? > > I was able to process a 8700x6000 pixel image when using 'time ./script.rb' > 440.005u 9.917s 8:27.20 88.7% 0+0k 0+0io 52012pf+0w > > So, around 7 minutes for 5 million pixels.. that's around 118000 > pixels per second. Hm. Oh well, it's fast enough for me. This > operation isn't done all that often. Although, a while ago I did > something like this in C with the GD library, and it took around 10-20 > seconds to process a similar sized image. > I'm not surprised that the 256-color IM is the fastest solution. I'm also not surprised that a pure-C solution is faster than a Ruby solution. All those channel values have to be converted from integers to Fixnums and back to integers, not to mention constructing 5M Magick::Pixel objects. Thanks for sharing what you learned. This'll be useful for the next guy to face a similar problem.