Re: Speeding up an application - general rules
- From: "Petyr David" <phynkel@xxxxxxxxx>
- Date: 24 Dec 2006 13:54:10 -0800
You're correct: I use Perl's back tics to take output from a command
that looks similar to this to populate an array:
my @filepatterns=`find $subdir -n $days -type f -exec egrep $pattern {}
\; |sed "s/somepattern/diffpattern"`
I like using the find command because I can also control how many days
to go back in my search. I will also check Devl::DProf
On Dec 22, 12:15 am, Eric Schwartz <emsch...@xxxxxxxxx> wrote:
"Petyr David" <phyn...@xxxxxxxxx> writes:
Basically: the script uses perl's system command to run a long windedexample code. In fact, it's really kinda hard to say anything for
"find" command which is piped to sed to correct patterns that match
HTML markers.You are unclear here, which is why we generally ask you to post
sure because you didn't. I'm not sure, for instance, if you pipe the
output of find to sed, or if you iterate over the list of files
returned by find and run sed on the contents of those files. I'm
guessing the former, but it's just a guess. If you want people to be
able to help you the best way possible, you probably don't want to
make them guess.
The matching lines are then shoved into an array.Which lines? Are you talking about contents of the files, or names offiles? Now I think you're talking about contents. It would help if
you were more clear.
The elements of the array are moved into a hash for the purpose of
sorting the file names.Er, now I think you're talking about file names.
Then file names and matching lines are printed.Now I have no idea. What are you actually doing? Can you please showsome code?
Q: Can I speed things by eliminating the sed command and letting Perl"how do I speed things up?" is profile profile profile! Until you
filter and modify the matching patterns? If so, how much of a
performance gain?Honestly, rather than asking us, you should ask Perl. The answer to
profile, you don't know what will help.
'perldoc -q profile' mentions the Devel::DProf module, and you can use
'perldoc Devel::DProf' to find out more about it. You'll also want to
learn about the Benchmark module ('perldoc Benchmark'), which will
help you compare two different ways of doing the same thing to find
out which is faster.
Is using Perl's grep to search through every file for the patternrecall that the Windows 'find' command searches in files, whereas the
faster than using the find command?Wait, are you on Windows? It's been a very long time, but I vaguely
Unix one mostly just looks at file names and metadata.
The find command has the advantage that I can search for files of aincluding your system's OS, configuration, load for other tasks, etc,
certain date rather easily. Again: could that be done more rapidly
by Perl's looking at the file's mod time?Those questions really depend on uch a large a number of things,
that it's almost impossible for anyone to tell you for certain.
Honestly, even if somebody were to give you an answer here, I wouldn't
believe them-- they may be telling you what worked for them, but it
might not be the same for you. Profile, then optimize the
worst-performing part, then profile again, optimize what's left, and
repeat. Take care that in optimizing one part you don't make another
slower-- but that's all part of the art, really.s
Any thoughts or suggestions would be appreciatedEnjoy. But next time, please post some code, so we can actulaly tellwhat you're doing. Making people guess and make stuff up is
frustrating for us, because we can't tell if we're guessing right, or
going completely off the deep end. I hope I was helpful anyway.
-=Eric
.
- References:
- Speeding up an application - general rules
- From: Petyr David
- Re: Speeding up an application - general rules
- From: Eric Schwartz
- Speeding up an application - general rules
- Prev by Date: Re: BEST PERL BOOK FOR SYSTEM ADMINISTRATION UNIX
- Next by Date: Re: Speeding up an application - general rules
- Previous by thread: Re: Speeding up an application - general rules
- Next by thread: Re: Speeding up an application - general rules
- Index(es):
Relevant Pages
|