NAME

DashProfiler - collect call count and timing data aggregated by context

SYNOPSIS

The DashProfiler modules enable you to efficiently collect performance data by adding just a line of code to the functions or objects you want to monitor.

Data is aggregated by context and optionally also by a granular time axis.

See DashProfiler::UserGuide for a general introduction.

DESCRIPTION

Via DashProfiler::Import cost per call = 50,000/second, 0.000020s on modern box (not accurate to realworld situations because of L2 caching, but the general message that "it's fast" is)

USE IN APACHE

Example Apache mod_perl Configuration

<Perl>
BEGIN {
    # create profile early so other code can use DashProfiler::Import
    use DashProfiler;
    # files will be written to $spool_directory/dashprofiler.subsys.ppid.pid
    DashProfiler->add_profile('subsys', {
        granularity => 30,
        flush_interval => 60,
        add_exclusive_sample => 'other',
        spool_directory => '/tmp', # needs write permission for apache user
    });
}
</Perl>

# hook DashProfiler into appropriate mod_perl handlers
PerlChildInitHandler DashProfiler::reset_all_profiles
PerlPostReadRequestHandler DashProfiler::start_sample_period_all_profiles
PerlCleanupHandler DashProfiler::end_sample_period_all_profiles
PerlChildExitHandler DashProfiler::flush_all_profiles

add_profile

DashProfiler->add_profile( 'my_profile_name' );
DashProfiler->add_profile( my_profile_name => { ... } );
$core = DashProfiler->add_core( my_profile_name => { ... } );

Calls DashProfiler::Core->new to create a new DashProfiler::Core object and then caches it, using the name as the key, so it can be refered to by name.

See DashProfiler::Core for details of the arguments.

prepare

$sampler = DashProfiler->prepare($profile_name, ...);

Calls prepare(...) on the DashProfiler named by $profile_name.

If no profile with that name exists then it will warn, but only once per name.

get_profile

$core = DashProfiler->get_profile( $profile_name );

Returns the DashProfiler::Core object associated with that name.

profile_as_text

$text = DashProfiler->profile_as_text( $profile_name )

Calls profile_as_text(...) on the DashProfiler named by $profile_name. Returns undef if no profile with that name exists.

all_profiles_as_text

@text = DashProfiler->all_profiles_as_text

Calls profile_as_text() on all profiles, ordered by name.

dump_all_profiles

dump_all_profiles()

Equivalent to

warn $_ for DashProfiler->all_profiles_as_text();

reset_all_profiles

Calls reset_profile_data for all profiles. Then calls start_sample_period_all_profiles()

Typically called from mod_perl PerlChildInitHandler.

flush_all_profiles

flush_all_profiles()

Calls flush() for all profiles. Typically called from mod_perl PerlChildExitHandler

start_sample_period_all_profiles

start_sample_period_all_profiles()

Calls start_sample_period() for all profiles. Typically called from mod_perl PerlPostReadRequestHandler

end_sample_period_all_profiles

end_sample_period_all_profiles()

Calls end_sample_period() for all profiles. Then calls flush_if_due() for all profiles. Typically called from mod_perl PerlCleanupHandler