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.
Create a new ProfileTap object that wraps the given object and calls the method named in send_to ever time a profile event happens.
# File lib/amalgalite/profile_tap.rb, line 108 def initialize( wrapped_obj, send_to = 'profile' ) unless wrapped_obj.respond_to?( send_to ) raise Amalgalite::Error, "#{wrapped_obj.class.name} does not respond to #{send_to.to_s} " end @delegate_obj = wrapped_obj @delegate_method = send_to @samplers = {} end
Record the profile information and send the delegate object the msg and time information.
# File lib/amalgalite/profile_tap.rb, line 122 def profile( msg, time ) unless sampler = @samplers[msg] msg = msg.gsub(/\s+/,' ') sampler = @samplers[msg] = ProfileSampler.new( msg ) end sampler.sample( time ) @delegate_obj.send( @delegate_method, msg, time ) end
Generated with the Darkfish Rdoc Generator 2.