DBIx-Profile

 view release on metacpan or  search on metacpan

Profile.pm  view on Meta::CPAN

#
# Version: 1.0
# Jeff Lathan
# Kerry Clendinning
#
# Aaron Lee
#    Deja.com, 10-1999
# Michael G Schwern, 11-1999
#

#  Copyright (c) 1999,2000 Jeff Lathan, Kerry Clendinning.  All rights reserved. 
#  This program is free software; you can redistribute it and/or modify it 
#  under the same terms as Perl itself.

# .15 First public release.  Bad naming.
# .20 Fixed naming problems
# .30 Module is now more transparent, thanks to Michael G Schwern
#     One less "To Do" left!
#     11-4-1999
# 1.0 Added ability to trace executes, chosen by an environment variable
#     Added capability of saving everything to a log file
#

#
# This package provides an easy way to profile your DBI-based application.
# By just "use"ing this module, you will enable counting and measuring
# realtime and cpu time for each and every query used in the application.
# The times are accumulated by phase: execute vs. fetch, and broken down by
# first fetch, subsequent fetch and failed fetch within each of the 
# fetchrow_array, fetchrow_arrayref, and fetchrow_hashref methods.  
# More DBI functions will be added in the future.
# 
# USAGE:
# Add "use DBIx::Profile;" or use "perl -MDBIx::Profile <program>"
# Add a call to $dbh->printProfile() before calling disconnect,
#    or disconnect will dump the information.
#
# To Do:
#    Make the printProfile code better
#    

##########################################################################
##########################################################################

=head1 NAME

  DBIx::Profile - DBI query profiler
  Version 1.0

  Copyright (c) 1999,2000 Jeff Lathan, Kerry Clendinning.  
  All rights reserved. 

  This program is free software; you can redistribute it and/or modify it 
  under the same terms as Perl itself.

=head1 SYNOPSIS

  use DBIx::Profile; or "perl -MDBIx::Profile <program>" 
  use DBI;
  $dbh->printProfile();

=head1 DESCRIPTION

  DBIx::Profile is a quick and easy, and mostly transparent, profiler
  for scripts using DBI.  It collects information on the query 
  level, and keeps track of first, failed, normal, and total amounts
  (count, wall clock, cput time) for each function on the query.

  NOTE: DBIx::Profile use Time::HiRes to clock the wall time and
  the old standby times() to clock the cpu time.  The cpu time is
  pretty coarse.

  DBIx::Profile can also trace the execution of queries.  It will print 
  a timestamp and the query that was called.  This is optional, and 
  occurs only when the environment variable DBIXPROFILETRACE is set 
  to 1. (ex: (bash) export DBIXPROFILETRACE=1).

  Not all DBI methods are profiled at this time.
  Except for replacing the existing "use" and "connect" statements,
  DBIx::Profile allows DBI functions to be called as usual on handles.

  Prints information to STDERR, prefaced with the pid.

=head1 RECIPE

  1) Add "use DBIx::Profile" or execute "perl -MDBIx::Profile <program>"
  2) Optional: add $dbh->printProfile (will execute during 
     disconnect otherwise)
  3) Run code
  4) Data output will happen at printProfile or $dbh->disconnect;

=head1 METHODS

  printProfile
     $dbh->printProfile();

     Will print out the data collected.
     If this is not called before disconnect, disconnect will call
     printProfile.

  setLogFile
     $dbh->setLogFile("ProfileOutput.txt");

     Will save all output to the file.

=head1 AUTHORS

  Jeff Lathan, lathan@pobox.com
  Kerry Clendinning, kerry@deja.com

  Aaron Lee, aaron@pointx.org
  Michael G Schwern, schwern@pobox.com

=head1 SEE ALSO

  L<perl(1)>, L<DBI>

=cut

#
# For CPAN and Makefile.PL
#
$VERSION = '1.0';



( run in 1.698 second using v1.01-cache-2.11-cpan-fe3c2283af0 )