The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
readability vs. speed

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ryan Davis

Posts: 651
Nickname: zenspider
Registered: Oct, 2004

Ryan Davis is a ruby nerd.
readability vs. speed Posted: Sep 17, 2007 9:12 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Ryan Davis.
Original Post: readability vs. speed
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ryan Davis
Latest Posts From Polishing Ruby

Advertisement

Which one is better? You decide...

if true then # 0.75 seconds
  require 'active_record'
  require 'yaml'
  require 'app/models/author'
  require 'app/models/project'
  config = YAML.load(File.read('config/database.yml'))
  ActiveRecord::Base.establish_connection(config["development"])
else # 2.0 seconds
  require File.dirname(__FILE__) + '/../config/environment'
end

conn = ActiveRecord::Base.connection

I'm slightly partial to the faster running one (esp. during development)... but it did take me a while to figger it out. Loading config/environment a heavy price to pay just to get a DB connection and automatic requires.

Read: readability vs. speed

Topic: Who is Ron Paul? Previous Topic   Next Topic Topic: More fun!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use