Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Performance: Perl versus compiled programs

Reply
Thread Tools

Performance: Perl versus compiled programs

 
 
Ben Morrow
Guest
Posts: n/a
 
      01-13-2004

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Apart from that, Perl programs generally have some startup cost
> (parsing and compiling) that you need to factor out. If you have a
> program that spends a large amount of time (relative to the startup
> time) processing text, Perl might actually beat a C program.


Perl *is* a C program. Therefore is is always possible to write a C
program which will run at least as fast as any given Perl program. The
question, as always with optimization, is 'is it worth it?'. And the
answer is nearly always 'no'.

Ben

--
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
(E-Mail Removed) <=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=> (Kate Rusby)
 
Reply With Quote
 
 
 
 
Martien Verbruggen
Guest
Posts: n/a
 
      01-13-2004
On Tue, 13 Jan 2004 04:22:20 +0000 (UTC),
Ben Morrow <(E-Mail Removed)> wrote:
>
> (E-Mail Removed) wrote:
>> Apart from that, Perl programs generally have some startup cost
>> (parsing and compiling) that you need to factor out. If you have a
>> program that spends a large amount of time (relative to the startup
>> time) processing text, Perl might actually beat a C program.

>
> Perl *is* a C program. Therefore is is always possible to write a C
> program which will run at least as fast as any given Perl program. The
> question, as always with optimization, is 'is it worth it?'. And the
> answer is nearly always 'no'.


I agree, and I hope that that sentiment was clear from the rest of
what I wrote.

Of course, you can always link in the Perl libraries, and write a C
program using the Perl internals.

Martien
--
|
Martien Verbruggen | This matter is best disposed of from a great
Trading Post Australia | height, over water.
|
 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      01-13-2004
Alan J. Flavell <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> On Fri, 9 Jan 2004 (E-Mail Removed) wrote:
>
> > (E-Mail Removed) (Yash) wrote:
> >
> > > I am primarily asking about whether writing a program in Perl can
> > > cause significant performance impact.

> >
> > Yes, it can.

>
> I'm sure your answer is precisely correct: "yes, it *can*".


[good stuff snipped]

> I don't myself recall a situation where an application was ever turned
> from being impractical into feasible merely by recoding in a different
> language. I do, however, recall an occasion where a task that needed
> 3 days computation was re-examined from scratch, and a totally
> different algorithm was used, bringing the time down to about 20
> minutes. ...


It is also common for a slow program to spend most of the time in one
or two "hot spots". With a Perl program, these can be identified by
profiling and possibly re-coded in C. Using the Inline module, this
can be done almost transparently, so you end up with something that
is structurally still a Perl program, but with nearly the speed of a
compiled binary. If your program has those hot spots, that is...

Anno
 
Reply With Quote
 
pkent
Guest
Posts: n/a
 
      01-14-2004
In article <(E-Mail Removed) >,
(E-Mail Removed) (Yash) wrote:

> I have a PERL program that reads from a large text file and does some
> processing on every line it reads. If this same program is written in
> C or any other compiled language, would I get significant performance
> improvement?


It's certainly possible that the perl program can be faster than the C
one. It might be _much_ faster.

OTOH it might be slower, although that might be 'a small amount slower'.
It may depend on a lot of things, including how good the C programmer is
and how good the perl programmer is.

In this scenario I guess that program will run for a relative 'long'
time, which means the startup time for perl and the compilation phase
might be relatively small, which leaves us with the runtime speed being
the deciding factor. Perl is written in C, and once a perl program has
been compiled it's full steam ahead.


> I am primarily asking about whether writing a program in Perl can
> cause significant performance impact.


In general, none at all, but the parameters of what is acceptable all
depend on your particular needs and circumstances (which you haven't
mentioned so I'm giving the general answer).

P

--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Mozilla versus IE versus Opera versus Safari Peter Potamus the Purple Hippo Firefox 0 05-08-2008 12:56 PM
If I create a page, then it's compiled upon first request, where cani find the compiled code?? lander ASP .Net 5 03-05-2008 04:34 PM
equal? versus eql? versus == versus === verus <=> Paul Butcher Ruby 12 11-28-2007 06:06 AM
g++ compiled C++ code called from gcc compiled C code Klaus Schneider C++ 1 12-02-2004 01:44 PM
compiled dll's versus aspx.cs =?Utf-8?B?Ry5ILkxhd3JlbmNl?= ASP .Net 2 04-07-2004 09:25 PM



Advertisments