Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will Perl be the bottleneck in this kind of image processing?

The processing I have in mind is this:

  • there are thousands of png files
  • each of them should be loaded, and its pixels accessed
  • each pixel's channels will be processed in some way, and then written to a binary file

I was thinking of using some sort of module, like ImageMagick wrappers, or some other wrapper for a C image processing backend. Will Perl slow me down if I choose it to implement this task? I have a tool already that's written in Java ( it uses JDK's BufferedImage ), and it's reasonably fast. Would I be crazy to expect the same speed from Perl?

like image 928
Geo Avatar asked Dec 04 '22 13:12

Geo


2 Answers

If you're using ImageMagick, or other any other C-based processing tool, perl will most certainly not be the bottleneck. The bottlenecks I could see (especially if processing thousands of files) would be:

  • Disk IO speeds
  • Memory access speeds
  • Library algorithm speed

Perl will make a great glue for doing what you want. The slow parts will still be slow. You might as well make the fast parts easy. :)

Also, remember the two Rules of Optimization:

  1. Don't do it.
  2. (For experts only: ) Don't do it yet.

When you do get it put together, run a profiler on it. If and when that becomes your goal, check out:

http://metacpan.org/pod/Devel::NYTProf

Devel::NYTProf is pretty much the bee's knees when it comes to profiling tools. It'll show you exactly where your slowdowns are, so you don't just have a "warm fuzzy" feeling that you have it right...you'll know for sure.

like image 56
Robert P Avatar answered Dec 21 '22 22:12

Robert P


I don't think so, unless your Perl code is over-reliant on method calls in a tight loop. But if the actual image processing is done in C backend, Perl will not be a bottleneck performance-wise.

like image 23
DVK Avatar answered Dec 22 '22 00:12

DVK