Skip to content

Commit

Permalink
added profile environment for perftools profiling (1.9.3 only)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Mar 11, 2013
1 parent 45c4382 commit 22a4580
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,8 @@ end
# If you want to amend mini profiler to do the monkey patches in the railstie
# we are open to it.
gem 'rack-mini-profiler', git: 'git://github.com/SamSaffron/MiniProfiler'

# perftools only works on 1.9 atm
group :profile do
gem 'rack-perftools_profiler', require: 'rack/perftools_profiler', platform: :mri_19
end
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,11 @@ GEM
omniauth-twitter (0.0.14)
multi_json (~> 1.3)
omniauth-oauth (~> 1.0)
open4 (1.3.0)
openid-redis-store (0.0.2)
redis
ruby-openid
perftools.rb (2.0.0)
pg (0.14.1)
polyglot (0.3.3)
progress (2.4.0)
Expand All @@ -325,6 +327,10 @@ GEM
rack-openid (1.3.1)
rack (>= 1.1.0)
ruby-openid (>= 2.1.8)
rack-perftools_profiler (0.6.0)
open4 (~> 1.0)
perftools.rb (~> 2.0.0)
rack (~> 1.0)
rack-protection (1.3.2)
rack
rack-ssl (1.3.3)
Expand Down Expand Up @@ -514,6 +520,7 @@ DEPENDENCIES
pg
pry-rails
rack-mini-profiler!
rack-perftools_profiler
rails
rails_multisite!
rake
Expand Down
1 change: 1 addition & 0 deletions app/models/topic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def fancy_title
return title unless SiteSetting.title_fancy_entities?

# We don't always have to require this, if fancy is disabled
# see: http://meta.discourse.org/t/pattern-for-defer-loading-gems-and-profiling-with-perftools-rb/4629
require 'redcarpet' unless defined? Redcarpet

Redcarpet::Render::SmartyPants.render(title)
Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
Bundler.require(*Rails.groups(:assets => %w(development test profile)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
Expand Down
10 changes: 10 additions & 0 deletions config/database.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ production:
timeout: 5000
host_names:
- production.localhost # Update this to be the domain of your production site

profile:
adapter: postgresql
database: discourse_development
min_messages: warning
host: localhost
pool: 5
timeout: 5000
host_names:
- "localhost"
45 changes: 45 additions & 0 deletions config/environments/profile.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Discourse::Application.configure do
# Settings specified here will take precedence over those in config/application.rb

# Code is not reloaded between requests
config.cache_classes = true

# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true

# in profile mode we serve static assets
config.serve_static_assets = true

# Compress JavaScripts and CSS
config.assets.compress = true

# stuff should be pre-compiled, allow compilation to make life easier
config.assets.compile = true

# Generate digests for assets URLs
config.assets.digest = true

# Specifies the header that your server uses for sending files
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true

config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {arguments: '-i'}

# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify

# I dunno ... perhaps the built-in minifier is using closure
# regardless it is blowing up
config.ember.variant = :development
config.ember.ember_location = "#{Rails.root}/app/assets/javascripts/external_production/ember.js"
config.ember.handlebars_location = "#{Rails.root}/app/assets/javascripts/external/handlebars-1.0.rc.3.js"
config.handlebars.precompile = true

config.middleware.use ::Rack::PerftoolsProfiler, :default_printer => 'gif'

end
2 changes: 1 addition & 1 deletion config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Discourse::Application.config.secret_token = "SET_SECRET_HERE"

# delete all lines below in production
if Rails.env.test? || Rails.env.development?
if Rails.env.test? || Rails.env.development? || Rails.env == "profile"
Discourse::Application.config.secret_token = "47f5390004bf6d25bb97083fb98e7cc133ab450ba814dd19638a78282b4ca291"
else
raise "You must set a secret token in ENV['SECRET_TOKEN'] or in config/initializers/secret_token.rb" if ENV['SECRET_TOKEN'].blank?
Expand Down
3 changes: 3 additions & 0 deletions config/redis.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ defaults: &defaults
development:
<<: *defaults

profile:
<<: *defaults

test:
<<: *defaults
db: 1
Expand Down

0 comments on commit 22a4580

Please sign in to comment.