Skip to content

Commit

Permalink
[webui] use mini-profiler to make the bottlenecks clear
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Oct 10, 2012
1 parent 8836d68 commit e505962
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/webui/Gemfile
Expand Up @@ -17,6 +17,10 @@ group :development do
gem 'pry', '>= 0.9.8.4'
#gem 'pry-doc', '>= 0.4.1'
gem 'sqlite3'

# See http://railscasts.com/episodes/368-miniprofiler
gem 'rack-mini-profiler'
#gem 'stacktrace'
end

group :test do
Expand All @@ -38,3 +42,4 @@ gem 'fast_xs'
gem 'memcache-client', :require => false
gem 'jquery-rails'
gem 'mobileesp_converted'

3 changes: 3 additions & 0 deletions src/webui/Gemfile.lock
Expand Up @@ -82,6 +82,8 @@ GEM
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
rack-mini-profiler (0.1.22)
rack (>= 1.1.3)
rack-ssl (1.3.2)
rack
rack-test (0.6.2)
Expand Down Expand Up @@ -156,6 +158,7 @@ DEPENDENCIES
mysql2
nokogiri (~> 1.5.0)
pry (>= 0.9.8.4)
rack-mini-profiler
rails (~> 3.2.8)
rdoc
sass-rails
Expand Down
5 changes: 5 additions & 0 deletions src/webui/config/initializers/activexml.rb
Expand Up @@ -132,3 +132,8 @@ def add(d)

end

if Rails.env.development?
::Rack::MiniProfiler.profile_method(ActiveXML::Transport::Rest, :http_do) { |method,url| "#{method.to_s.upcase} #{url.path}?#{url.query}" }
# ::Rack::MiniProfiler.profile_method(ActiveXML::Base, :find_cached) { "Fetching" }
end

8 changes: 4 additions & 4 deletions src/webui/lib/tasks/cleanup_sessions.rake
Expand Up @@ -2,12 +2,12 @@ namespace :db do
desc "Deletes sessions not running - run often"
task :cleanup_sessions => :environment do
abcs = ActiveRecord::Base.configurations
case abcs[RAILS_ENV]["adapter"]
when "mysql"
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
case abcs[Rails.env]["adapter"]
when "mysql2"
ActiveRecord::Base.establish_connection(abcs[Rails.env])
ActiveRecord::Base.connection.execute 'DELETE FROM sessions WHERE updated_at < DATE_SUB(NOW(), INTERVAL 1 DAY)'
else
raise "Task not supported by '#{abcs[RAILS_ENV]["adapter"]}'"
raise "Task not supported by '#{abcs[Rails.env]["adapter"]}'"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/webui/tmp/.gitignore
@@ -1 +1 @@
sass-cache
*

0 comments on commit e505962

Please sign in to comment.