### Home Classes Methods

### In Files

- lib/amalgalite/profile_tap.rb

### Parent

Object

### Methods

- ::new
- #profile

### Files

- HISTORY.rdoc
- LICENSE
- README.rdoc

### Class/Module Index

Quicksearch

- Amalgalite
- Amalgalite::Aggregate
- Amalgalite::Blob
- Amalgalite::Blob::Error
- Amalgalite::Boolean
- Amalgalite::BusyHandler
- Amalgalite::BusyTimeout
- Amalgalite::CSVTableImporter
- Amalgalite::Column
- Amalgalite::Database
- Amalgalite::Database::AggregateError
- Amalgalite::Database::BusyHandlerError
- Amalgalite::Database::FunctionError
- Amalgalite::Database::InvalidModeError
- Amalgalite::Database::ProgressHandlerError
- Amalgalite::Database::TransactionBehavior
- Amalgalite::Error
- Amalgalite::Function
- Amalgalite::Index
- Amalgalite::MemoryDatabase
- Amalgalite::Packer
- Amalgalite::Paths
- Amalgalite::ProfileSampler
- Amalgalite::ProfileTap
- Amalgalite::ProgressHandler
- Amalgalite::Requires
- Amalgalite::SQLite3
- Amalgalite::SQLite3::Constants
- Amalgalite::SQLite3::Constants::Config
- Amalgalite::SQLite3::Constants::DBStatus
- Amalgalite::SQLite3::Constants::DataType
- Amalgalite::SQLite3::Constants::Helpers
- Amalgalite::SQLite3::Constants::Open
- Amalgalite::SQLite3::Constants::ResultCode
- Amalgalite::SQLite3::Constants::StatementStatus
- Amalgalite::SQLite3::Constants::Status
- Amalgalite::SQLite3::Database
- Amalgalite::SQLite3::Database::DBStatus
- Amalgalite::SQLite3::Database::Function
- Amalgalite::SQLite3::Database::Stat
- Amalgalite::SQLite3::Stat
- Amalgalite::SQLite3::Status
- Amalgalite::SQLite3::Version
- Amalgalite::Schema
- Amalgalite::Statement
- Amalgalite::Table
- Amalgalite::Taps
- Amalgalite::Taps::IO
- Amalgalite::Taps::Stderr
- Amalgalite::Taps::Stdout
- Amalgalite::Taps::StringIO
- Amalgalite::TraceTap
- Amalgalite::TypeMap
- Amalgalite::TypeMaps
- Amalgalite::TypeMaps::DefaultMap
- Amalgalite::TypeMaps::StorageMap
- Amalgalite::TypeMaps::TextMap
- Amalgalite::Version
- Amalgalite::View
- Kernel
- Object

No matching classes.

# Amalgalite::ProfileTap

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.

### Attributes

samplers[R]

### Public Class Methods

new( wrapped_obj, send_to = 'profile' ) click to toggle source

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

### Public Instance Methods

profile( msg, time ) click to toggle source

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.