Speeding Up This Script

R

Robert Love

This is my first ruby script. It does what I want but seems dead dog
slow compared to just using shell tools like "ls" and "grep". I will
expand its purpose later but for now I just want to look at all files in
a directory and identify those that have a certain CVS tag.

Please give me advice on how to speed it up using other techniques.
Thanks.

#!/home/u102k/bin/ruby -W0

target = Regexp.new('SR_048999')

Dir['*.f'].each do |zfile|
zline = `cvs log #{zfile}`.grep(target)
if zline.length != 0 then
printf("%s %s", zfile, zline)
end
end
 
R

Robert Klemme

Robert said:
This is my first ruby script. It does what I want but seems dead dog
slow compared to just using shell tools like "ls" and "grep". I will
expand its purpose later but for now I just want to look at all files in
a directory and identify those that have a certain CVS tag.

Please give me advice on how to speed it up using other techniques.
Thanks.

#!/home/u102k/bin/ruby -W0

target = Regexp.new('SR_048999')

Dir['*.f'].each do |zfile|
zline = `cvs log #{zfile}`.grep(target)
if zline.length != 0 then
printf("%s %s", zfile, zline)
end
end

Invoke "cvs log" only once for all files or use a CVS lib for ruby.

Kind regards

robert
 
R

Robert Love

In said:
Robert said:
This is my first ruby script. It does what I want but seems dead dog
slow compared to just using shell tools like "ls" and "grep". I will
expand its purpose later but for now I just want to look at all files
in a directory and identify those that have a certain CVS tag.
Please give me advice on how to speed it up using other techniques.
Thanks.

#!/home/u102k/bin/ruby -W0

target = Regexp.new('SR_048999')

Dir['*.f'].each do |zfile|
zline = `cvs log #{zfile}`.grep(target)
if zline.length != 0 then
printf("%s %s", zfile, zline)
end
end

Invoke "cvs log" only once for all files or use a CVS lib for ruby.

Do you know of such a library? Googling ruby & cvs give tons of results
but I don't see any such library. Thanks for the pointers.
 
R

Robert Klemme

Robert said:
In said:
Robert said:
This is my first ruby script. It does what I want but seems dead dog
slow compared to just using shell tools like "ls" and "grep". I will
expand its purpose later but for now I just want to look at all files
in a directory and identify those that have a certain CVS tag.
Please give me advice on how to speed it up using other techniques.
Thanks.

#!/home/u102k/bin/ruby -W0

target = Regexp.new('SR_048999')

Dir['*.f'].each do |zfile|
zline = `cvs log #{zfile}`.grep(target)
if zline.length != 0 then
printf("%s %s", zfile, zline)
end
end
Invoke "cvs log" only once for all files or use a CVS lib for ruby.

Do you know of such a library? Googling ruby & cvs give tons of results
but I don't see any such library. Thanks for the pointers.

http://www.google.de/search?q=ruby+...ient=firefox-a&rls=org.mozilla:en-US:official

second hit

RAA is also a good place to look:

http://raa.ruby-lang.org/search.rhtml?search=cvs

Cheers

robert
 
H

Hew Wolff

Please give me advice on how to speed it up using other techniques.

What does the profiler point to?

Hew Wolff
 
R

Robert Love

In said:
#!/home/u102k/bin/ruby -W0

target = Regexp.new('SR_048999')

Dir['*.f'].each do |zfile|
zline = `cvs log #{zfile}`.grep(target)
if zline.length != 0 then
printf("%s %s", zfile, zline)
end
end

Invoke "cvs log" only once for all files or use a CVS lib for ruby.

Switching to performing "cvs log" only once on all files collectivley
did speed things up but I had to do a little more parsing and grep'ing.
My example went from 6 seconds to 0.3 seconds this way. I also used `ls *.
f` instead of Ruby's Dir function.

Thanks for the advice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top