in reply to Re: PDF::API2 processing time
in thread PDF::API2 processing time
Is this your normal indentation? Looks horrible. Check out perltidy, a script than can repair this.
I would also suggest using
use strict; use warnings;
I see you have practically just one really big loop where you process each record. It would have been easy to do some really basic profiling by just putting print "Doing xyz now\n" every few lines and observing whether that minute for each record is wasted in one place or distributed evenly.
Please read How do I post a question effectively?. You could have done the profiling before posting the code and then would have known which part of the code is important to post. You could have provided sample data (a few records) so that other monks could run your code.
I don't have any experience with PDF::API2, but I'm guessing that a lot of the stuff you have in your loop could be moved before the loop. Definitely all the constant strings you create, all the font assignments, probably also the assignments of $pdb, $jpeg, $png, $tag. Just try it and see if it works.
The same could be done with the images of the chars. Your code probably can be changed to:
my %char_pics=(); # before the big loop while(<DATAFILE>){ ... foreach(@chars) { if(!$_ == "") { if (exists $char_pics{$_}) { $img= $char_pics{$_}; } else { $img=$pdf->image_png("/var/www/html/font_test/Pumpkins +/$_.png"); $char_pics{$_}= $img; } vr->image(... ...
If this works it could be quite a speedup since each char has to be read only once from disk instead of every time it is printed
|
---|