Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > how to make my ruby code faster?

Reply
Thread Tools

how to make my ruby code faster?

 
 
罗晟
Guest
Posts: n/a
 
      01-05-2012
hi there, I just write a ruby program mirror to its python version to
feel the difference between the two fantastic language. here is the
ruby code. http://paste.pocoo.org/show/530185/. But I found it
twice slower(1.09 seconds to run) than its python counterpart(0.34
seconds to run). I think I made some mistake in writing this ruby
code. How can I make the ruby code faster? I'm using MRI 1.9.2, and
the file 0103.log is a 60000 lines file.
 
Reply With Quote
 
 
 
 
Robert Klemme
Guest
Posts: n/a
 
      01-05-2012
On 01/05/2012 04:18 AM, 罗晟 wrote:
> hi there, I just write a ruby program mirror to its python version to
> feel the difference between the two fantastic language. here is the
> ruby code. http://paste.pocoo.org/show/530185/. But I found it
> twice slower(1.09 seconds to run) than its python counterpart(0.34
> seconds to run). I think I made some mistake in writing this ruby
> code. How can I make the ruby code faster? I'm using MRI 1.9.2, and
> the file 0103.log is a 60000 lines file.


I don't have a mysql handy nor can I afford the time to set up one right
now. Also it's hard without documentation and explanation what the code
is supposed to do. You could start though with replacing your include?
chek in is_bad with a regexp match. I can see a few more micro
optimizations but it's better to first tackle the overall design. Did
you try running with "ruby -r profile"?

Cheers

robert

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to make an unix library from some ruby code? Pavel Smerk Ruby 7 03-18-2008 07:03 PM
I am new to Ruby and I could use some expert advice as to how I can make this code run faster. Ruby Maniac Ruby 57 09-27-2007 04:47 PM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
how to make corresponding java code for html code david wolf Java 1 04-21-2006 09:58 PM



Advertisments