3021: Add web-inspectable profiling mode.
authorTom Clegg <tom@curoverse.com>
Tue, 13 Jan 2015 15:18:16 +0000 (10:18 -0500)
committerTom Clegg <tom@curoverse.com>
Tue, 13 Jan 2015 15:18:16 +0000 (10:18 -0500)
* Run Workbench with environment variable ENABLE_PROFILING=yes. Timing
  figures should appear at the top left of each page. Click to get
  more detail.

* Visit {workbench-uri}?pp=flamegraph to see a profiling graph instead
  of the requested page itself.

* More: https://github.com/MiniProfiler/rack-mini-profiler

apps/workbench/Gemfile
apps/workbench/Gemfile.lock
apps/workbench/config/initializers/rack_mini_profile.rb [new file with mode: 0644]

index 3a226489d9678cee2a5461518f7784dadb2e1286..eb383800f24d1044a9d66a3b45e6423cd2483671 100644 (file)
@@ -1,7 +1,7 @@
 source 'https://rubygems.org'
 
 gem 'rails', '~> 4.1.0'
-gem 'arvados', '>= 0.1.20141114230720'
+gem 'arvados', '>= 0.1.20150111195521'
 
 gem 'sqlite3'
 
@@ -29,6 +29,8 @@ end
 group :development do
   gem 'byebug'
   gem 'ruby-debug-passenger'
+  gem 'rack-mini-profiler', require: false
+  gem 'flamegraph', require: false
 end
 
 group :test, :diagnostics do
index 4132189ad46193baee4394c7d2e04d1e880e49fe..c72f2564f1cee9d51e8bd0cd181be0d5e85e7281 100644 (file)
@@ -40,7 +40,7 @@ GEM
     andand (1.3.3)
     angularjs-rails (1.3.8)
     arel (5.0.1.20140414130214)
-    arvados (0.1.20141114230720)
+    arvados (0.1.20150111195521)
       activesupport (>= 3.2.13)
       andand (~> 1.3, >= 1.3.3)
       google-api-client (~> 0.6.3, >= 0.6.3)
@@ -94,7 +94,12 @@ GEM
     extlib (0.9.16)
     faraday (0.8.9)
       multipart-post (~> 1.2.0)
+    fast_stack (0.1.0)
+      rake
+      rake-compiler
     ffi (1.9.6)
+    flamegraph (0.1.0)
+      fast_stack
     google-api-client (0.6.4)
       addressable (>= 2.3.2)
       autoparse (>= 0.3.3)
@@ -160,6 +165,8 @@ GEM
       multi_json (~> 1.0)
       websocket-driver (>= 0.2.0)
     rack (1.5.2)
+    rack-mini-profiler (0.9.2)
+      rack (>= 1.1.3)
     rack-test (0.6.3)
       rack (>= 1.0)
     rails (4.1.9)
@@ -179,6 +186,8 @@ GEM
       rake (>= 0.8.7)
       thor (>= 0.18.1, < 2.0)
     rake (10.4.2)
+    rake-compiler (0.9.5)
+      rake
     raphael-rails (2.1.2)
     ref (1.0.5)
     ruby-debug-passenger (0.2.0)
@@ -249,7 +258,7 @@ DEPENDENCIES
   RedCloth
   andand
   angularjs-rails
-  arvados (>= 0.1.20141114230720)
+  arvados (>= 0.1.20150111195521)
   bootstrap-sass (~> 3.1.0)
   bootstrap-tab-history-rails
   bootstrap-x-editable-rails
@@ -257,6 +266,7 @@ DEPENDENCIES
   capybara
   coffee-rails
   deep_merge
+  flamegraph
   headless
   httpclient (~> 2.5)
   jquery-rails
@@ -270,6 +280,7 @@ DEPENDENCIES
   passenger
   piwik_analytics
   poltergeist
+  rack-mini-profiler
   rails (~> 4.1.0)
   rails-perftest
   raphael-rails
diff --git a/apps/workbench/config/initializers/rack_mini_profile.rb b/apps/workbench/config/initializers/rack_mini_profile.rb
new file mode 100644 (file)
index 0000000..a554734
--- /dev/null
@@ -0,0 +1,5 @@
+if not Rails.env.production? and ENV['ENABLE_PROFILING']
+  require 'rack-mini-profiler'
+  require 'flamegraph'
+  Rack::MiniProfilerRails.initialize! Rails.application
+end