Class Amalgalite::ProfileTap
In: lib/amalgalite/profile_tap.rb
Parent: Object

A Profile Tap recives profile events from SQLite which involve the number of nanoseconds in wall-clock time it took for a particular thing to happen. In general this thing is an SQL statement.

It has a well known profile method which when invoked will write the event to a delegate object.

Methods

new   profile  

Attributes

samplers  [R] 

Public Class methods

Create a new ProfileTap object that wraps the given object and calls the method named in send_to ever time a profile event happens.

[Source]

     # File lib/amalgalite/profile_tap.rb, line 107
107:     def initialize( wrapped_obj, send_to = 'profile' )
108:       unless wrapped_obj.respond_to?( send_to ) 
109:         raise Amalgalite::Error, "#{wrapped_obj.class.name} does not respond to #{send_to.to_s} "
110:       end
111: 
112:       @delegate_obj    = wrapped_obj
113:       @delegate_method = send_to
114:       @samplers        = {}
115:     end

Public Instance methods

Record the profile information and send the delegate object the msg and time information.

[Source]

     # File lib/amalgalite/profile_tap.rb, line 121
121:     def profile( msg, time )
122:       unless sampler = @samplers[msg] 
123:         msg = msg.gsub(/\s+/,' ')
124:         sampler = @samplers[msg] = ProfileSampler.new( msg )
125:       end
126:       sampler.sample( time )
127:       @delegate_obj.send( @delegate_method, msg, time )
128:     end

[Validate]