Will Perl be the bottleneck in such image processing?

The processing that I have in mind is this:

  • there are thousands of png files
  • each of them must be loaded, and its pixels are available
  • each pixel channel will be processed in some way and then written to a binary file

I thought to use some kind of module, for example, ImageMagick wrappers or some other shell for the image processing backend C. Will Perl slow me down if I choose it for this task? I already have a tool written in Java (it uses the JDK BufferedImage) and it is fast enough. Will I be crazy to expect the same speed from Perl?

+4
source share
4 answers

If you use ImageMagick or other other C-based processing tools, perl will certainly not be a bottleneck. The bottlenecks that I could see (especially when processing thousands of files) would be as follows:

  • Disk I / O speed
  • Memory access speed
  • Library algorithm speed

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

Also remember the two optimization rules:

  • Do not do that.
  • (For experts only :) Don't do this yet.

When you connect it, run the profiler. If and when it becomes your goal, check:

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

Devel :: NYTProf is pretty much the bee's knees when it comes to profiling tools. He will show you exactly where the slowdown occurs, so you do not just have a โ€œwarm fuzzyโ€ feeling that everything is fine with you ... you will understand this for sure.

+9
source

I donโ€™t think so if your Perl code is independent of method calls in a narrow loop. But if the actual image processing is done on a C server, Perl will not be a performance bottleneck.

+4
source

The answer depends on performance limitations in the Java version. If you are limited to file I / O (including decompressing .png), then switching to Perl will probably be fine. Otherwise, you probably pay a hefty performance penalty to process each pixel in Perl, but if you can call C procedures to process whole images, you will probably be as fast (probably faster, depending on relative performance C and Java libraries).

So, in short: if Perl should touch pixels, it will be slow. If Perl touches images and C touches pixels, this is probably great.

+3
source

Yes, I expect perl implementation performance to be incredibly high when manipulating images at the pixel level.

Yes, you could do it, but Perl's data structures are not that way. If you used a library in which you do not need to make a 1x call per pixel, you will still be.

+1
source

Source: https://habr.com/ru/post/1301215/


All Articles