(JaLuMarkPro) Jangan Lupakan Benchmark dan Profile

Posted: March 5, 2007 in ノート, Ruby on Rails, Technology
sayang:~/toombila arie$ script/performance/benchmarker 'Department.find_all_for_select_option'
            user     system      total        real
#1      0.000000   0.000000   0.000000 (  0.004361)
sayang:~/toombila arie$ script/performance/profiler 'Department.find_all_for_select_option'
Loading Rails...
Using the standard Ruby profiler.
  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 16.86     1.64      1.64        2   820.00  3485.00  Array#sort
 16.65     3.26      1.62      501     3.23     7.98  Gem::Version#
  8.12     4.05      0.79     4185     0.19     0.22  Numeric#nonzero?
  5.65     4.60      0.55      500     1.10     1.16  Gem::Specification#full_name
  5.14     5.10      0.50     1003     0.50     0.93  Array#map
[cut]
  0.00     9.73      0.00        1     0.00    50.00  Module#const_missing
  0.00     9.73      0.00       12     0.00     0.00  Kernel.block_given?
 -0.00     9.73     -0.00        1    -0.00  9680.00  Department#find_all_for_select_option
  0.00     9.73      0.00        1     0.00  9730.00  #toplevel
sayang:~/toombila arie$ r -e'IO.readlines("app/models/department.rb").display'
class Department  "can't be blank"
  validates_uniqueness_of :name, :message => "must be unique"
  
  # self.find_all_for_select_option
  # SELECT * FROM departments => and then make it as an array containing name and id values
  def self.find_all_for_select_option
    find(:all).map { |e| [e.name, e.id] }
  end
end
sayang:~/toombila arie$ 

tinggalkan feedback konstruktif atau lebih baik diam

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s