"Jeffrey W. Baker" wrote:
> 
> On Thu, 18 May 2000, brian moseley wrote:
> 
> > On Thu, 18 May 2000, Autarch wrote:
> > pretty slow if you build a string using .= instead of using
> > smarter methods, like pushing strings onto an array and then
> > joining it.
> 
> You tried to sell me that when I was at CP, and I didn't buy it then
> either.  This is a benchmark of .= versus join.  500000 20-byte strings
> are joined:
> 
>     Concat:  2 wallclock secs ( 1.34 usr +  0.27 sys =  1.61 CPU)
>       Join:  4 wallclock secs ( 3.63 usr +  0.19 sys =  3.82 CPU)
> 
> .= concatenation is way faster.  Also, building a 500000-element array in
> Perl takes up vastly more memory than building a 10000000-byte string.
> The string and the Perl process together require an RSS of 11MB, while the
> array and the Perl process eat an RSS of 51MB.

seems very odd. ".=" copies the string every time, and then
concatenates the new addition to the end. "join" may do something
internally like that, but i'd expect it to be optimized.

and so what?

that's all moot when it comes to generating html; you push strings
and then simply print:

        @table = ();
        loop { 
                @tr = ();
                loop { 
                        ...
                        push(@row,"<td>",$data,"</td>\n");
                }
                push(@table,"<tr>",@row,"</tr>\n");
        }
        ...
        print(@table,$str,$val,$other);

(you could easily use more object-oriented CGI-like methods, 
of course...)

no joining or concatenation needed.

-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Their is five errers in this sentance.

Reply via email to