sprintf patch and alternate root class kludge, MANIFEST and Changes files... master
authorivan <ivan>
Tue, 28 Sep 2004 01:23:28 +0000 (01:23 +0000)
committerivan <ivan>
Tue, 28 Sep 2004 01:23:28 +0000 (01:23 +0000)
Changes [new file with mode: 0644]
MANIFEST [new file with mode: 0644]
Profile.pm
debian/changelog [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/rules [new file with mode: 0755]

diff --git a/Changes b/Changes
new file mode 100644 (file)
index 0000000..1e0e675
--- /dev/null
+++ b/Changes
@@ -0,0 +1,9 @@
+Revision history for Perl extension DBIx::Profile.
+
+1.01  unreleased
+       - new maintainer
+       - add sprintf patch
+       - add kludge to get along with DBIx::ContextualFetch
+
+1.00  original verison
+
diff --git a/MANIFEST b/MANIFEST
new file mode 100644 (file)
index 0000000..f68882b
--- /dev/null
+++ b/MANIFEST
@@ -0,0 +1,4 @@
+Makefile.PL
+Profile.pm
+README
+MANIFEST
index 13f9d37..4e27a5c 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Version: 1.0
+# Version: 1.01
 # Jeff Lathan
 # Kerry Clendinning
 #
@@ -7,6 +7,7 @@
 #    Deja.com, 10-1999
 # Michael G Schwern, 11-1999
 #
+# Current maintainer: Ivan Kohler <ivan-dbix-profile@420.am>
 
 #  Copyright (c) 1999,2000 Jeff Lathan, Kerry Clendinning.  All rights reserved. 
 #  This program is free software; you can redistribute it and/or modify it 
@@ -19,7 +20,8 @@
 #     11-4-1999
 # 1.0 Added ability to trace executes, chosen by an environment variable
 #     Added capability of saving everything to a log file
-#
+# 1.01 Added sprintf patch, MANIFEST and Changes files, and kludge to get
+#      along with DBIx::ContextualFetch
 
 #
 # This package provides an easy way to profile your DBI-based application.
@@ -45,7 +47,7 @@
 =head1 NAME
 
   DBIx::Profile - DBI query profiler
-  Version 1.0
+  Version 1.01
 
   Copyright (c) 1999,2000 Jeff Lathan, Kerry Clendinning.  
   All rights reserved. 
   use DBI;
   $dbh->printProfile();
 
+  #or to use with things like like to be the DBI root class themselves:
+  # (Class::DBI / Ima::DBI uses DBIx::ContextualFetch)
+  use DBIx::Profile ( RootClass=>'DBIx::ContextualFetch' );
+
 =head1 DESCRIPTION
 
   DBIx::Profile is a quick and easy, and mostly transparent, profiler
      If this is not called before disconnect, disconnect will call
      printProfile.
 
+  sprintProfile
+     $profile = $dbh->sprintPRofile();
+
+     Returns the data collected.
+
   setLogFile
      $dbh->setLogFile("ProfileOutput.txt");
 
   Aaron Lee, aaron@pointx.org
   Michael G Schwern, schwern@pobox.com
 
+  Current maintainer: Ivan Kohler <ivan-dbix-profile@420.am>
+
 =head1 SEE ALSO
 
   L<perl(1)>, L<DBI>
 
 =cut
 
-#
-# For CPAN and Makefile.PL
-#
-$VERSION = '1.0';
+package DBIx::Profile;
 
+use strict;
+use vars qw(@ISA $VERSION);
 use DBI;
 
-package DBIx::Profile;
+$VERSION = '1.01';
+
+@ISA = qw(DBI);
 
 # Store DBI's original connect & disconnect then replace it with ours.
 {
@@ -132,11 +146,6 @@ package DBIx::Profile;
     *_DBI_connect = DBI->can('connect');
     *DBI::connect = \&connect;
 }
-use strict;
-use vars qw(@ISA);
-
-@ISA = qw(DBI);
 
 #
 # Make DBI aware of us.
@@ -151,6 +160,19 @@ if ($ENV{DBIXPROFILETRACE}) {
     $DBIx::Profile::DBIXTRACE = 1;
 }
 
+sub import {
+  my( $self, %opt ) = @_;
+  if ( $opt{RootClass} ) {
+    eval "use $opt{RootClass}";
+    #*_DBI_connect = UNIVERSAL::can( $opt{'RootClass'}, 'connect' );
+    #*DBI::connect = \&connect;
+    unshift @DBIx::Profile::ISA, $opt{RootClass};
+    unshift @DBIx::Profile::db::ISA, $opt{RootClass}. '::db';
+    unshift @DBIx::Profile::st::ISA, $opt{RootClass}. '::st';
+    #__PACKAGE__->init_rootclass;
+  }
+}
+
 sub connect {
     my $self = shift;
     my $result = __PACKAGE__->_DBI_connect(@_);
@@ -225,9 +247,16 @@ sub DESTROY {
 # JEFF - The printing and the print code is kinda (er... very) ugly!
 #
 
+#like printProfile, except returns the results instead of printing them.
+sub sprintProfile {
+    my $self = shift;
+    $self->printProfile({'sprint'=>1});
+}
+
 sub printProfile {
 
     my $self = shift;
+    my $args = shift;
     my %result;
     my $total = 0;
     no integer;
@@ -292,13 +321,18 @@ sub printProfile {
        $result{$total} = $text;
     } # each query
 
+    my $results;
     foreach my $qry (sort stripsort keys %result) {
-       if ($DBIx::Profile::DBIXFILE eq "" ) {
+        if ( $args->{'sprint'} ) {
+            $results .= $result{$qry} . "\n";
+        } elsif ($DBIx::Profile::DBIXFILE eq "" ) {
            warn $result{$qry} . "\n";
        } else {
            print $DBIx::Profile::DBIXFILEHANDLE $result{$qry} . "\n";
        }
     }
+
+    return $results if $args->{'sprint'};
 }
     
 sub stripsort {
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..b5fe637
--- /dev/null
@@ -0,0 +1,30 @@
+libdbix-profile-perl (1.01-1) unstable; urgency=low
+
+  * New upstream, new upstream release.
+
+ -- Ivan Kohler <ivan-debian@420.am>  Mon, 27 Sep 2004 05:25:02 -0700
+
+libdbix-profile-perl (1.0-3) unstable; urgency=low
+
+  * debian/copyright pedantry (closes: Bug#153331, Bug#153392)
+  * binary-arch vs. binary-indep (closes: Bug#153353)
+  * updated description from ddtp (closes: Bug#156303)
+  * remove spurious files in .diff (closes: Bug#153395)
+
+ -- Ivan Kohler <ivan-debian@420.am>  Sat,  7 Sep 2002 05:07:05 -0700
+
+libdbix-profile-perl (1.0-2) unstable; urgency=low
+
+  * corrected spelling in description and manpage (closes: Bug#124932)
+
+ -- Ivan Kohler <ivan-debian@420.am>  Mon, 17 Dec 2001 15:27:35 -0800
+
+libdbix-profile-perl (1.0-1) unstable; urgency=low
+
+  * Initial Release (closes: Bug#103669)
+
+ -- Ivan Kohler <ivan-debian@420.am>  Sun,  8 Jul 2001 15:59:58 -0700
+
+Local variables:
+mode: debian-changelog
+End:
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..f291305
--- /dev/null
@@ -0,0 +1,24 @@
+Source: libdbix-profile-perl
+Section: interpreters
+Priority: optional
+Build-Depends: debhelper (>= 3.0.5), perl (>= 5.6.0-17)
+Maintainer: Ivan Kohler <ivan-debian@420.am>
+Standards-Version: 3.5.1
+
+Package: libdbix-profile-perl
+Architecture: all
+Depends: ${perl:Depends}, libtime-hires-perl, libdbi-perl
+Description:  DBI query profiler
+ 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, CPU 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).
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..b1cb494
--- /dev/null
@@ -0,0 +1,13 @@
+This is the debian package for the DBIx::Profile module.
+It was created by Ivan Kohler <ivan-debian@420.am> using dh-make-perl.
+
+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.
+
+Perl is distributed under your choice of the GNU General Public License or
+the Artistic License.  On Debian GNU/Linux systems, the complete text of the
+GNU General Public License can be found in `/usr/share/common-licenses/GPL'
+and the Artistic Licence in `/usr/share/common-licenses/Artistic'.
+
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..6acde0d
--- /dev/null
@@ -0,0 +1,88 @@
+#!/usr/bin/make -f
+#-*- makefile -*-
+# Made with the aid of dh_make, by Craig Small
+# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
+# Some lines taken from debmake, by Christoph Lameter.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+export DH_COMPAT=3
+
+PACKAGE=$(shell dh_listpackages)
+
+ifndef PERL
+PERL = /usr/bin/perl
+endif
+
+ifndef DESTDIR
+DESTDIR=..
+endif
+TMP     =`pwd`/debian/$(PACKAGE)
+
+build: build-stamp
+build-stamp:
+       dh_testdir
+
+       
+       # Add here commands to compile the package.
+       $(PERL) Makefile.PL INSTALLDIRS=vendor
+       $(MAKE) OPTIMIZE="-O2 -g -Wall"
+
+       touch build-stamp
+
+clean:
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp
+
+       # Add here commands to clean up after the build process.
+       -$(MAKE) realclean
+
+       dh_clean
+
+install: 
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+
+       # Add here commands to install the package into debian/tmp.
+       #$(MAKE) install DESTDIR=`pwd`/debian/tmp
+       $(MAKE) install PREFIX=$(TMP)/usr
+
+
+# Build architecture-dependent files here.
+binary-arch: build install
+# We have nothing to do by default.
+
+# Build architecture-independent files here.
+binary-indep: build install
+#      dh_testversion
+       dh_testdir
+       dh_testroot
+       dh_installdocs README
+       dh_installexamples
+       dh_installmenu
+#      dh_installemacsen
+#      dh_installinit
+       dh_installcron
+       dh_installmanpages
+#      dh_undocumented
+       dh_installchangelogs 
+       dh_link
+       dh_strip
+       dh_compress
+       dh_fixperms
+#      dh_makeshlibs
+       dh_installdeb
+       dh_perl 
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb --destdir=$(DESTDIR)
+
+source diff:                                                                  
+       @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary