hi -

is there a way to track what SQL queries DM is creating behind the
scenes?

also, any recommended ways to track down the timing around the
queries?
we have a spec as per the below using ruby-prof that gives some basic
times/split between DM and merb, but its fairly rough cut. i was
wondering what other ways people are digging into optimizing their
apps with DM?

tx,

/dc

----

require File.join(File.dirname(__FILE__), 'spec_helper.rb')

describe Application do


  it "should give me some profiling" do

    #pending "disabling this pending line and loading the dev
database.  run this spec alone."
    puts "Please don't take these numbers too seriously"

    require 'ruby-prof'

    { :avatars => url(:controller => 'avatars', :action => 'play', :id
=> '3', :format => 'swf'),
      :homes => url(:controller => 'homes', :action => 'user', :id =>
'3', :format => 'swf'),
      :quests => url(:controller => 'quests', :action =>
'bouncer', :id => 'entry', :guid=>'ON', :format => 'swf')
    }.each_pair do |k,v|
      puts "Profiling #{k.to_s}"

      result = RubyProf.profile do
        request(v, {}, {'HTTP_X_UP_SUBNO' => 'xx', "HTTP_USER_AGENT"
=> 'xx-'} )
      end

      sums = {:'DataMapper::'=>0,  :'Merb::'=>0}
      total = 0

      result.threads.values.each do |thread| thread.each do |method|
        sums.keys.each do |klass|
          sums[klass] += method.self_time if method.klass_name.include?
(klass.to_s)
        end
        total += method.self_time
      end; end

      sums.each_pair do |klass, time|
        puts "\t#{klass.to_s[0..4]}:\t\t#{(time/total*100).to_s[0..4]}%
\t\t#{time.to_s[0..4]}s"
      end

      puts "\ttotal:\t\t100%\t\t#{total.to_s[0..4]}s"
      File.open(File.dirname(__FILE__)+"/../log/
#{k.to_s}_profile.html",'w') do |s|
          printer = RubyProf::GraphHtmlPrinter.new(result)
          printer.print(s, :min_percent=>3)
      end

    end
  end

end


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to