Perl optimisation help
Peter
plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Thu Jun 8 19:37:14 UTC 2006
On Thu, 8 Jun 2006, Lennart Sorensen wrote:
> On Thu, Jun 08, 2006 at 10:16:13PM +0300, Peter wrote:
>> is there some tool that helps optimise Perl, in the manner of gprof or
>> similar ?
>
> man Devel::DProf
> man dprofpp
>
> Use is something like:
>
> # perl -d:DProf myscript.pl
> # dprofpp
>
> A temp file called tmon.out is created which is what dprofpp looks at.
> dprofpp has options to display different information too.
Wow, that was fast ;-) Your answer got here before the echo of my own
message. Thanks, that was useful.
But more exactly, does anyone know a more efficient way to increase a
string variable's length, written like:
$var = $var.$more
where this needs to be done 100,000 times in realtime (say, a few
seconds) ?
$more is usually a line of text (~80chars) and $var can grow to 8 Megs.
I have thought of using a hash indexed by line numbers instead of a
simple var. This will almost certainly be faster (depending on how
horribly (?) the '.' operator is implemented). Before I do this, has
anyone got a pointer to a discussion document on such issues ?
'.' seems to run in O(n^2) so far. Maybe Perl uses the C string storage
convention internally instead of Pascal ? (ouch)
thanks,
Peter
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list