in reply to String Concatenation Performance

Somehow, I can't imagine your code is doing nothing else than concatenating strings in a tight loop. Even if so, you're already benchmarking close to 1,400,000 concats/sec. Are you sure you should care about the relative performance of interpolation and concatenation, and not be looking for another algorithm or writing C code instead?

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: String Concatenation Performance
by pbeckingham (Parson) on Mar 20, 2004 at 19:00 UTC

    Oh I agree completely - there is not much to be gained here, but in general, I still want to know the degree to which interpolation is slower. My problem is all about isolating test cases that show this. For example, the following are all going to perform slightly differently, and I just want to understand:

    print "$a$b$c\n"; print $a, $b, $c, "\n";
    or how about:
    my $s = $a . $b . $c . "\n"; my $s = "$a$b$c\n";
      Your first pair can be significantly different, depending on the relative performance of concatenation vs your I/O system. However, your second pair should always be identical, statistically speaking. They always compile down to identical opcodes, as chromatic pointed out. There's no point in comparing them to see which one is faster, because you're pretty much guaranteed not to get a statistically signicant difference, and if you ever do, you didn't. :-)