Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: which is faster, interpolation or concatenation?

by Flexx (Pilgrim)
on Sep 09, 2002 at 10:50 UTC ( [id://196205]=note: print w/replies, xml ) Need Help??


in reply to which is faster, interpolation or concatenation?

Stas Bekman and the mod_perl folks have looked into this before. You'll find a more general answer there.

Fellow monks, don't kill me, but I'm quite disappointed with your, let's say, 'evading' answers. While I do agree that for the most time speed considerations at this scope are irrelevant, there are situations (like a mod_perl CGI under rapid fire) where you need every bit of speed you can get. Also noone considered that the length of strings would probably have (quite some) impact on what's faster.

It might be but a loop or subroutine that's part of a (much) larger project, so "don't use perl if you need speed" is quite an ignorant advice. antichef asked us what's faster in Perl, he didn't ask whether Perl was fastest in the first place...

So long,
Flexx

  • Comment on Re: which is faster, interpolation or concatenation?

Replies are listed 'Best First'.
Re: Re: which is faster, interpolation or concatenation?
by perrin (Chancellor) on Sep 09, 2002 at 13:28 UTC
    there are situations (like a mod_perl CGI under rapid fire) where you need every bit of speed you can get

    The point of upbraiding this monk for his question is that the energy being spent here would be better spent somewhere else. Nearly anywhere else. Asking "which way of doing almost nothing is faster, and maintainability be damned" is a bad attitude and deserves criticism. The method of concatenation will not be the performance bottleneck in any mod_perl script that does anything of significance. Stas was criticized by several people on the list for doing this benchmark, since it only serves to fuel this kind of counterproductive behavior. People need to learn how to do it right: build it, profile it, fix the slow parts, repeat.

Re(2): which is faster, interpolation or concatenation?
by Arien (Pilgrim) on Sep 09, 2002 at 22:43 UTC
    There are situations (like a mod_perl CGI under rapid fire) where you need every bit of speed you can get.

    After profiling you may find that the performance you are looking for cannot be achieved using your setup. More memory, changing the Apache/mod_perl configuration, a faster processor, more processors, or not doing the bottleneck in Perl (if that's where the bottleneck is) are some of the ways to help you get there.

    It might be but a loop or subroutine that's part of a (much) larger project, so "don't use perl if you need speed" is quite an ignorant advice.

    Just to make sure: that advice wasn't given.

    antichef asked us what's faster in Perl, he didn't ask whether Perl was fastest in the first place...

    Assuming he has a performance problem (and not just some theoretical curiosity), maybe he should have. Besides, one form could be rewritten to the other by the optimizer in another Perl version, so what's the point?

    — Arien

      OK - thanks everyone. Here's why I asked: I wrote and run a site - spamgourmet.com, which is a disposable email address service. I wrote the code and most of the supporting website (all perl) in a couple of weekends. The service now has many thousands of users and processes a great deal of mail every day.

      The site has been up for almost two years, during which it has cost me $10 per month. I'm still nowhere close to exceeding the limits placed on my account by my hosting company (he.net - gushing endorsement goes here), and I look forward to keeping it that way. I've also sworn to myself and anyone else who'll listen that the service will always be free - that is, not a source of revenue for anybody. (I suppose I plan to simply stop accepting new users when I hit the ceiling, and then encourage others to take up the cause for new users.) Sales of t-shirts, coffee mugs, etc. during this period have netted $17.01 - not enough for cafepress.com to dislodge a check. I've also received a $10 donation. I couldn't care less. To justify this position to (the many) naysayers in my day-to-day life, I can truthfully say that I spend about as much time and money on the service as going to the movies once a month.

      The codebase is small - I've open-sourced it, but I'm not aware of anyone using or extending the code, so my focus is more on keeping the users happy, and keeping the service cheap - so, yes, I'm counting bits. Nevertheless, my aim to maintain balance in these things discourages me from using the scientific method too liberally...

      So I came here seeking wisdom. I've been told that string concatenation is a real killer in java. I suspected the same was not true in Perl, but I thought I'd ask here, and my suspicion has been abundantly confirmed. Thanks again.

      Hi Arien,

      It might be but a loop or subroutine that's part of a (much) larger project, so "don't use perl if you need speed" is quite an ignorant advice.
      Just to make sure: that advice wasn't given.

      No hard feelings! Somehow I read it that way, but I understand that you didn't mean it that way. My bad.

      Look, I gave a pointer to more information on the question being asked. antichef didn't state what's behind his question, so any assumtion on that is just that -- an assumtion. The only thing he has stated was that he did not worry about readability but for speed only, and he got several "don't/bad boy/shame on you" answers. I gave him a pointer to information he was asking for -- so what did I do wrong?

      I didn't mean to object on any of the advice given, on the contrary, I agreed in principle.

      Besides, one form could be rewritten to the other by the optimizer in another Perl version, so what's the point?

      Fine. But what's the point in your objection? Right now, one way might indeed be faster than the other, and brother antichef was courious. I don't know what's wrong with that. Those who know me, know that I am on a crusade for good style and ethics myself, but it's still ok to be courious!

      So long
      Flexx

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://196205]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-18 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found