Compile vs mod_perl vs perl

B

Bill H

Background:
I have a program that uses PDF:API2 to generate pdf files based on
html text and images. When done it then generates preview images of
the pages using Imagemagik. The program does not interaface with the
web so there is no communication with a browser.

The questions I have are, is there any significant speed increase
going to mod_perl or even compiling it to an executable? From what I
have heard and read (and this could be wrong), the mod_perl just keeps
it in memory so that it is faster getting started and that compiling
just wraps the code in a perl script interpreter (for lack of a better
term). Are these true?

Looking at perldoc perlcompile it mentions that it will make C source
out of your perl script but then gives caveats about how it is
incomprehensible. Discounting this, since I could always make changes
to the perl code and "re-compile", does it actually make c source will
compile to an executable? What about included Libs (such as the
PDF:API2)? Do they get "compiled" also?

Bill H
 
A

A. Sinan Unur

Background:
I have a program that uses PDF:API2 to generate pdf files based on
html text and images. When done it then generates preview images of
the pages using Imagemagik. The program does not interaface with the
web so there is no communication with a browser.

The questions I have are, is there any significant speed increase
going to mod_perl

mod_perl works within Apache, so I don't think it is relevant to your
situation.
or even compiling it to an executable? From what I
have heard and read (and this could be wrong), the mod_perl just keeps
it in memory so that it is faster getting started and that compiling
just wraps the code in a perl script interpreter (for lack of a better
term). Are these true?

Yes. In the most naive scenario, mod_perl represents a speedup over CGI
by not going through the whole invoke perl, compile modules etc routine
every time a Perl script is invoked via Apache.

Yes to the second question as well.
Looking at perldoc perlcompile it mentions that it will make C source
out of your perl script but then gives caveats about how it is
incomprehensible. Discounting this, since I could always make changes
to the perl code and "re-compile", does it actually make c source will
compile to an executable? What about included Libs (such as the
PDF:API2)? Do they get "compiled" also?

I do not know the internals. I do not care about the internals.

If you are looking to speed up your program, trying to compile to C is
the last avenue you should be considering. It is better to look at how
your program does what it does and identify what it does slowly and
which of those tasks that it does slowly represents opportunities for a
speed-up by changes to code or algorithm.

http://www.perl.com/pub/a/2001/06/27/ctoperl.html

http://www.perl.com/pub/a/2004/06/25/profiling.html


Sinan



--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
 
P

Peter J. Holzer

From what I have heard and read (and this could be wrong), [...]
compiling just wraps the code in a perl script interpreter (for lack
of a better term). Are these true?

That depends on the "perl compiler". The programs which turn a perl
program into an executable, usually just pack the perl program, the
modules it uses and a perl interpreter into an executable. They are
sometimes calles "compilers", but the don't compile (in the IT sense of
the word) anything.
Looking at perldoc perlcompile it mentions that it will make C source
out of your perl script but then gives caveats about how it is
incomprehensible.

Perlcc is the exception. Perlcc really translates Perl into C which can
then be compiled into a native executable. The problem is that it
doesn't work for most Perl programs. It is considered a failed
experiment and has been removed from perl 5.10.

hp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top