[Tutor] performance considerations
Mon, 3 Dec 2001 13:31:13 -0500
On Mon, Dec 03, 2001 at 01:10:41PM -0500, Andrei Kulakov wrote:
| On Mon, Dec 03, 2001 at 12:51:39PM -0500, dman wrote:
| > I'm working on a script/program to do some processing (munging) on
| > text files in a directory tree. In addition, for convenience, all
| > non-interesting files are copied without munging. My script, as it
| > stands, is quite CPU intensive so I would like to optimize it some.
| > In the case of copying non-interesting files, what is (generally) the
| > most efficient way? It seems there is no system-level "copy" command.
| > A portion of the script generates strings by starting with 'a' and
| > "adding" to it. Ie "a", "b", ..., "z", "aa", "ab", ..., "zz", "aaa".
| > Would it be better to use a list of one-char-strings than to modify a
| > single string? Here's the code I have now (BTW, that funny-looking
I forgot to mention, if a list of strings is used, each yield will
yield "".join( the_list ), so the comparison is the multiple
modifications (creation) of strings versus join.
| I believe so.. profile!
| > One last question for now :
| > I traverse the interesting files line-by-line and check them for a
| > regex match, then modify the line if it matches properly. Would it be
| > better (faster) to read in the whole file and treat it as a single
| > string? Memory is not a problem.
| Yeah, probably.. profile!
I want to speculate before I rewrite it :-). Maybe Tim will tell me
something (since he is so familiar with the inner workings)?
How to shoot yourself in the foot with Java:
You find that Microsoft and Sun have released imcompatible class
libraries both implementing Gun objects. You then find that although
there are plenty of feet objects implemented in the past in many other
languages, you cannot get access to one. But seeing as Java is so cool,
you dont care and go around shooting anything else you can find.
(written by Mark Hammond)