Class: Rack::MiniProfiler::TimerStruct::Page
- Defined in:
- lib/mini_profiler/timer_struct/page.rb
Overview
TimerStruct::Page
Root: TimerStruct::Request
:has_many TimerStruct::Request children
:has_many TimerStruct::Sql children
:has_many TimerStruct::Custom children
Instance Method Summary collapse
- #duration_ms ⇒ Object
-
#initialize(env) ⇒ Page
constructor
A new instance of Page.
- #root ⇒ Object
- #to_json(*a) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(env) ⇒ Page
Returns a new instance of Page.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mini_profiler/timer_struct/page.rb', line 11 def initialize(env) timer_id = MiniProfiler.generate_id page_name = env['PATH_INFO'] started_at = (Time.now.to_f * 1000).to_i machine_name = env['SERVER_NAME'] super( :id => timer_id, :name => page_name, :started => started_at, :machine_name => machine_name, :level => 0, :user => "unknown user", :has_user_viewed => false, :client_timings => nil, :duration_milliseconds => 0, :has_trivial_timings => true, :has_all_trivial_timings => false, :trivial_duration_threshold_milliseconds => 2, :head => nil, :duration_milliseconds_in_sql => 0, :has_sql_timings => true, :has_duplicate_sql_timings => false, :executed_readers => 0, :executed_scalars => 0, :executed_non_queries => 0, :custom_timing_names => [], :custom_timing_stats => {} ) name = "#{env['REQUEST_METHOD']} http://#{env['SERVER_NAME']}:#{env['SERVER_PORT']}#{env['SCRIPT_NAME']}#{env['PATH_INFO']}" self[:root] = TimerStruct::Request.createRoot(name, self) end |
Instance Method Details
#duration_ms ⇒ Object
43 44 45 |
# File 'lib/mini_profiler/timer_struct/page.rb', line 43 def duration_ms @attributes[:root][:duration_milliseconds] end |
#root ⇒ Object
47 48 49 |
# File 'lib/mini_profiler/timer_struct/page.rb', line 47 def root @attributes[:root] end |
#to_json(*a) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/mini_profiler/timer_struct/page.rb', line 51 def to_json(*a) attribs = @attributes.merge( :started => '/Date(%d)/' % @attributes[:started], :duration_milliseconds => @attributes[:root][:duration_milliseconds], :custom_timing_names => @attributes[:custom_timing_stats].keys.sort ) ::JSON.generate(attribs, :max_nesting => 100) end |