I have a script that generates several fairly complicated SVGs, places them in a folder, and then runs an external Java program to convert the folder of SVGs into a single PDF. Currently I'm calling the Java program from within my script as follows:

$report_failure = system('java -jar /var/www/helper_code/svg2pdf.jar ' + . "$output_files$invoice_data_ref->{'actual_invoice_id'}" . '/master +*.svg' . ' ' . "$output_files$invoice_data_ref->{'actual_invoice_id'} +" . '/master.pdf');
This works, but it is slower than I expect it to be. For example, if I generate the folder of SVGs, and then manually run the Java program from the shell it takes 5-6 seconds to create the PDF. However, executing the Java command from within my perl script takes 13 seconds. At first I thought this was just due to the overhead of calling any external command from within perl, but if I replace my call to system with a simpler call (e.g., system('java -version') ) then that call takes less than a second.

Any ideas on how to figure this out?

In reply to Speeding up external command execution by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.