Class: Insight::MemoryPanel
- Defined in:
- lib/insight/panels/memory_panel.rb
Instance Attribute Summary
Attributes inherited from Panel
Instance Method Summary collapse
- #after(env, status, headers, body) ⇒ Object
- #before(env) ⇒ Object
- #has_content? ⇒ Boolean
- #heading_for_request(number) ⇒ Object
-
#initialize(app) ⇒ MemoryPanel
constructor
A new instance of MemoryPanel.
- #name ⇒ Object
Methods inherited from Panel
#call, #content_for_request, current_panel_file, excluded, file_index, from_file, inherited, #panel_app, panel_exclusion, panel_mappings, #render
Methods included from Instrumentation::Client
#after_detect, #before_detect, #probe, #request_finish, #request_start
Methods included from Logging
Methods included from Database::RequestDataClient
#key_sql_template, #retrieve, #store, #table_length, #table_setup
Methods included from Render
#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params
Constructor Details
#initialize(app) ⇒ MemoryPanel
Returns a new instance of MemoryPanel.
4 5 6 7 |
# File 'lib/insight/panels/memory_panel.rb', line 4 def initialize(app) super table_setup("memory_records") end |
Instance Method Details
#after(env, status, headers, body) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/insight/panels/memory_panel.rb', line 13 def after(env, status, headers, body) total_memory = `ps -o rss= -p #{$$}`.to_i store(env, {:total_memory => total_memory, :memory_increase => total_memory - @original_memory, :original_memory => @original_memory}) end |
#before(env) ⇒ Object
9 10 11 |
# File 'lib/insight/panels/memory_panel.rb', line 9 def before(env) @original_memory = `ps -o rss= -p #{$$}`.to_i end |
#has_content? ⇒ Boolean
26 27 28 |
# File 'lib/insight/panels/memory_panel.rb', line 26 def has_content? false end |
#heading_for_request(number) ⇒ Object
20 21 22 23 24 |
# File 'lib/insight/panels/memory_panel.rb', line 20 def heading_for_request(number) record = retrieve(number).first "#{record[:memory_increase]} KB Δ, #{record[:total_memory]} KB total" end |
#name ⇒ Object
30 31 32 |
# File 'lib/insight/panels/memory_panel.rb', line 30 def name "Memory" end |