use rack-mini-profiler + the site proxy class was inefficient + do not ask for a session each time we need to query MongoDB
did
committed Aug 12, 2015
commit d4e06590633d18e4b708644480f8b698453feba5
Showing 6
changed files with
30 additions
and 3 deletions
Gemfile
+5
-0
| @@ | @@ -10,6 +10,11 @@ group :development do |
| gem 'thin' | |
| # gem 'sprockets-sass', '~> 1.2.0' | |
| gem 'yui-compressor', '~> 0.12.0' | |
| + | |
| + | gem 'rack-mini-profiler' |
| + | gem 'flamegraph' |
| + | gem 'stackprof' # ruby 2.1+ only |
| + | gem 'memory_profiler' |
| end | |
| group :test do | |
Gemfile.lock
+15
-0
| @@ | @@ -81,7 +81,12 @@ GEM |
| rack (>= 1.3.0) | |
| eventmachine (1.0.7) | |
| execjs (2.5.2) | |
| + | fast_stack (0.1.0) |
| + | rake |
| + | rake-compiler |
| ffi (1.9.10) | |
| + | flamegraph (0.1.0) |
| + | fast_stack |
| haml (4.0.7) | |
| tilt | |
| hike (1.2.3) | |
| @@ | @@ -109,6 +114,7 @@ GEM |
| activesupport (~> 4.2.1) | |
| colorize | |
| stringex (~> 2.5.2) | |
| + | memory_profiler (0.9.4) |
| method_source (0.8.2) | |
| mime-types (2.6.1) | |
| mimetype-fu (0.1.2) | |
| @@ | @@ -139,12 +145,16 @@ GEM |
| rack (1.6.1) | |
| rack-cache (1.2) | |
| rack (>= 0.4) | |
| + | rack-mini-profiler (0.9.7) |
| + | rack (>= 1.1.3) |
| rack-rewrite (1.5.1) | |
| rack-test (0.6.3) | |
| rack (>= 1.0) | |
| rack_csrf (2.5.0) | |
| rack (>= 1.1.0) | |
| rake (10.4.2) | |
| + | rake-compiler (0.9.5) |
| + | rake |
| rb-fsevent (0.9.5) | |
| rb-inotify (0.9.5) | |
| ffi (>= 0.5.0) | |
| @@ | @@ -187,6 +197,7 @@ GEM |
| sprockets-sass (1.3.1) | |
| sprockets (~> 2.0) | |
| tilt (~> 1.1) | |
| + | stackprof (0.2.7) |
| stringex (2.5.2) | |
| term-ansicolor (1.3.0) | |
| tins (~> 1.0) | |
| @@ | @@ -213,15 +224,19 @@ DEPENDENCIES |
| bundler (~> 1.7) | |
| codeclimate-test-reporter (~> 0.4.7) | |
| coveralls (~> 0.8.1) | |
| + | flamegraph |
| i18n-spec (~> 0.6.0) | |
| json_spec (~> 1.1.4) | |
| locomotivecms_steam! | |
| + | memory_profiler |
| moped (~> 2.0.6) | |
| origin (~> 2.1.1) | |
| pry-byebug (~> 3.1.0) | |
| + | rack-mini-profiler |
| rack-test (~> 0.6.3) | |
| rake (~> 10.4.2) | |
| rspec (~> 3.3.0) | |
| + | stackprof |
| thin | |
| timecop (~> 0.7.4) | |
| yui-compressor (~> 0.12.0) | |
bin/steam.rb
+1
-1
| @@ | @@ -8,7 +8,7 @@ Bundler.require |
| require 'thin' | |
| require 'optparse' | |
| - | server_options = { address: 'localhost', port: 8080 } |
| + | server_options = { address: '0.0.0.0', port: 8080 } |
| options = { | |
| adapter: { | |
locomotive/steam/adapters/mongodb.rb b/lib/locomotive/steam/adapters/mongodb.rb
+1
-1
| @@ | @@ -80,7 +80,7 @@ module Locomotive::Steam |
| end | |
| def session | |
| - | if uri |
| + | Thread.current[:moped_session] ||= if uri |
| Moped::Session.connect(uri) | |
| else | |
| Moped::Session.new([*hosts]).tap do |session| | |
locomotive/steam/server.rb b/lib/locomotive/steam/server.rb
+7
-0
| @@ | @@ -12,6 +12,11 @@ require 'dragonfly/middleware' |
| require_relative 'middlewares' | |
| + | if ENV['PROFILER'] |
| + | require 'moped' |
| + | require 'rack-mini-profiler' |
| + | end |
| + | |
| module Locomotive::Steam | |
| module Server | |
| @@ | @@ -38,6 +43,8 @@ module Locomotive::Steam |
| use Rack::Lint | |
| use Rack::Session::Moneta, configuration.moneta | |
| + | use Rack::MiniProfiler if ENV['PROFILER'] |
| + | |
| server.steam_middleware_stack.each { |k| use k } | |
| } | |
| end | |
locomotive/steam/services.rb b/lib/locomotive/steam/services.rb
+1
-1
| @@ | @@ -24,7 +24,7 @@ module Locomotive |
| end | |
| def __getobj__ | |
| - | super || @default.call |
| + | @site || (@site = @default.call) |
| end | |
| def nil? | |