Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Optimizing report generation

by Anonymous Monk
on Jun 19, 2012 at 18:44 UTC ( [id://977136]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have a web application that generates large, detailed PDF reports. The reports are created through a combination of Perl and Java. Perl is used to generate SVGs for each page of the report. The Perl script then calls two different Java programs via system and backticks. The first java program converts each SVG to a PDF. The second merges all of the PDFs into a single document which is returned to the Perl script. Finally, the Perl script stores the result in a database using DBI.

It's a complicated system, but it works well for generating the reports that we need. The problem is that it is slow. I think there is a significant amount of time being spent on startup, both for Perl as well as for each of the system commands. I can pretty easily make the Perl persistent. Is there a way to save time on the system commands that execute the Java programs? Unfortunately, replacing the Java isn't a viable option at this point.

Replies are listed 'Best First'.
Re: Optimizing report generation
by MidLifeXis (Monsignor) on Jun 19, 2012 at 20:02 UTC

    I think there is a significant amount of time being spent...

    Don't "think there is", profile, and know there is. Something as coarse grained as logging the start / stop times of each of the steps (see Time::HiRes) may be enough.

    --MidLifeXis

Re: Optimizing report generation
by thomas895 (Deacon) on Jun 19, 2012 at 22:26 UTC

    Also, large amounts of binary data(the PDFs) are best stored in files and not databases. While it might be handy, it can be rather slow, so you might want to try file-based storage.

    ~Thomas~
    confess( "I offer no guarantees on my code." );
Re: Optimizing report generation
by bulk88 (Priest) on Jun 20, 2012 at 00:36 UTC
    Your question is better suited for a java forum since as you said, you can't replace it.

    I can't see why you need java. PDFs are a tree-ish with some circular references, text format under the hood. From searching CPAN, I found CAM::PDF, which looks like it can manipulate the COS tree of a PDF. I've never used it personally. In other languages, I've written code that uses a PDF as a template, and using the PDF's COS tree format, fills in the data into the new PDF, not unlike HTML. Instead of java, you can try standalone text mode pdf tools, they will be faster than java since they are written in C/C++.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://977136]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-24 05:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found