From: Brian Adkins Date: 2007-03-07T12:35:08+09:00 Subject: High ActiveRecord CPU Utilization When running a test that primarily involves loading up a few MySQL tables with ActiveRecord objects, I was surprised to see the Ruby CPU utilization at 93% and the MySQL CPU utilization at 7%. I would expect this workload to be heavier on MySQL than that. I would think inserts (particularly with updating several foreign key indices) would tax the database more than Ruby. Has this been other folks' experience? Is running in the test environment incredibly different than production with respect to CPU utilization? I suppose my next step is to run in production to see what kind of results I get. I'm running the test from the root of my Rails project via: ruby test/unit/foo.rb Here's part of the profiler output: % time name 7.96 ActiveRecord::ConnectionAdapters::Quoting.quote 5.61 ActiveRecord::Base#read_attribute 5.15 ActiveRecord::Base#column_for_attribute 4.25 ActiveRecord::Base#connection 3.74 Hash#[] 3.58 Array#each 3.30 ActiveRecord::ConnectionAdapters::MysqlAdapter#quote 3.16 ActiveRecord::ConnectionAdapters::Column#type_cast 2.84 Module#=== 2.65 ActiveRecord::Base#clone_attribute_value 2.29 ActiveRecord::Base#write_attribute 2.24 Kernel.class 2.22 Hash#each 2.08 String#to_s 2.03 ActiveRecord::Base#quote_value 1.59 Kernel.send 1.55 Array#include? 1.52 Kernel.== 1.48 ActiveRecord::Base#unserializable_attribute? 1.39 Class#read_inheritable_attribute 1.34 Kernel.clone 1.29 ActiveRecord::Callbacks.notify 1.15 ActiveRecord::Base#method_missing 1.08 ActiveRecord::Base#columns_hash 1.08 ActiveRecord::Base#respond_to? 1.08 ActiveRecord::Callbacks.callback 0.99 Kernel.eval 0.95 Symbol#=== 0.90 Observable.notify_observers 0.88 ActiveRecord::ConnectionAdapters::Column#text? 0.85 Hash#[]= 0.85 Class#inheritable_attributes 0.83 Kernel.kind_of? 0.81 ActiveRecord::Base#convert_number_column_value ...