aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2011-07-25 11:27:37 +0100
committerRobin Houston <robin@lenny.robin>2011-07-25 21:58:46 +0100
commit8a252f033227b798a1261c73151d9b74b56da3cd (patch)
treef1a1c0a1b7c664be128687d0578fbc5b70891fc8 /app/controllers/application_controller.rb
parent63ac1e4faa8f8a312900cee2b959fa765e718872 (diff)
Add a flag to turn off logging memory usage, as (a) this is a debug setting, and (b) it's not cross-platform anyway (causes issues for people developing on OS X)
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 405327952..fe9ed7ec7 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -46,12 +46,17 @@ class ApplicationController < ActionController::Base
# egrep "CONSUME MEMORY: [0-9]{7} KB" production.log
around_filter :record_memory
def record_memory
- File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/)
- rss_before_action = $1.to_i
- yield
- File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/)
- rss_after_action = $1.to_i
- logger.info("PID: #{Process.pid}\tCONSUME MEMORY: #{rss_after_action - rss_before_action} KB\tNow: #{rss_after_action} KB\t#{request.url}")
+ record_memory = MySociety::Config.get('DEBUG_RECORD_MEMORY', false)
+ if record_memory
+ File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/)
+ rss_before_action = $1.to_i
+ yield
+ File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/)
+ rss_after_action = $1.to_i
+ logger.info("PID: #{Process.pid}\tCONSUME MEMORY: #{rss_after_action - rss_before_action} KB\tNow: #{rss_after_action} KB\t#{request.url}")
+ else
+ yield
+ end
end
# Set cookie expiry according to "remember me" checkbox, as per "An easier