r31709 - in /branches/upstream/libtemplate-timer-perl/current: Changes META.yml Makefile.PL README Timer.pm t/00-load.t t/eval.t t/pod.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Sun Mar 8 15:14:56 UTC 2009


Author: ansgar-guest
Date: Sun Mar  8 15:14:53 2009
New Revision: 31709

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=31709
Log:
[svn-upgrade] Integrating new upstream version, libtemplate-timer-perl (1.00)

Modified:
    branches/upstream/libtemplate-timer-perl/current/Changes
    branches/upstream/libtemplate-timer-perl/current/META.yml
    branches/upstream/libtemplate-timer-perl/current/Makefile.PL
    branches/upstream/libtemplate-timer-perl/current/README
    branches/upstream/libtemplate-timer-perl/current/Timer.pm
    branches/upstream/libtemplate-timer-perl/current/t/00-load.t
    branches/upstream/libtemplate-timer-perl/current/t/eval.t
    branches/upstream/libtemplate-timer-perl/current/t/pod.t

Modified: branches/upstream/libtemplate-timer-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-timer-perl/current/Changes?rev=31709&op=diff
==============================================================================
--- branches/upstream/libtemplate-timer-perl/current/Changes (original)
+++ branches/upstream/libtemplate-timer-perl/current/Changes Sun Mar  8 15:14:53 2009
@@ -1,23 +1,37 @@
 Revision history for Template::Timer
 
+Template::Timer is now hosted on github at
+http://github.com/petdance/template-timer/
+
+
+1.00    Fri Mar  6 23:32:49 CST 2009
+====================================
+[ENHANCEMENTS]
+Measurements are now in milliseconds, not seconds.
+
+Now shows nesting level in the notes.
+
+The times are all shown as a summary at the end, not throughout
+the page.
+
+
 0.04    Sun Oct 16 22:56:51 CDT 2005
+====================================
+[FIXES]
+When calling
 
-        [FIXES]
-        When calling
+    [% PROCESS block_1 + block_2 %]
 
-            [% PROCESS block_1 + block_2 %]
-
-        the block names are passed as an array reference to process().
-        Template::Timer was assuming that any ref() passed was an object
-        and calling ->name on that object.  Thanks to Bill Moseley.
+the block names are passed as an array reference to process().
+Template::Timer was assuming that any ref() passed was an object
+and calling ->name on that object.  Thanks to Bill Moseley.
 
 
 0.02    Tue Oct 26 11:08:33 CDT 2004
-
-        * First actual working version.  Fixed bonheaded typo.
+====================================
+First actual working version.  Fixed bonheaded typo.
 
 
 0.01    Tue Oct 26 09:58:24 CDT 2004
-
-        * First rudimentary version.  Patches and comments welcome.
-
+====================================
+First rudimentary version.  Patches and comments welcome.

Modified: branches/upstream/libtemplate-timer-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-timer-perl/current/META.yml?rev=31709&op=diff
==============================================================================
--- branches/upstream/libtemplate-timer-perl/current/META.yml (original)
+++ branches/upstream/libtemplate-timer-perl/current/META.yml Sun Mar  8 15:14:53 2009
@@ -1,13 +1,19 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
-name:         Template-Timer
-version:      0.04
-version_from: Timer.pm
-installdirs:  site
-requires:
+--- #YAML:1.0
+name:                Template-Timer
+version:             1.00
+abstract:            Rudimentary profiling for Template Toolkit
+license:             ~
+author:              
+    - Andy Lester <andy at petdance.com>
+generated_by:        ExtUtils::MakeMaker version 6.44
+distribution_type:   module
+requires:     
     Template:                      0
     Test::More:                    0
     Time::HiRes:                   0
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.30
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3
+resources:
+    license: http://dev.perl.org/licenses/
+    Repository: http://github.com/petdance/template-timer/

Modified: branches/upstream/libtemplate-timer-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-timer-perl/current/Makefile.PL?rev=31709&op=diff
==============================================================================
--- branches/upstream/libtemplate-timer-perl/current/Makefile.PL (original)
+++ branches/upstream/libtemplate-timer-perl/current/Makefile.PL Sun Mar  8 15:14:53 2009
@@ -2,7 +2,7 @@
 use warnings;
 use ExtUtils::MakeMaker;
 
-WriteMakefile(
+my %parms = (
     NAME                => 'Template::Timer',
     AUTHOR              => 'Andy Lester <andy at petdance.com>',
     VERSION_FROM        => 'Timer.pm',
@@ -16,3 +16,33 @@
     dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
     clean               => { FILES => 'Template-Timer-*' },
 );
+
+if ( $ExtUtils::MakeMaker::VERSION ge '6.36' ) {
+    $parms{EXTRA_META} = <<EOF;
+resources:
+    license: http://dev.perl.org/licenses/
+    Repository: http://github.com/petdance/template-timer/
+EOF
+}
+
+
+WriteMakefile( %parms );
+
+sub MY::postamble {
+    my $postamble = <<'MAKE_FRAG';
+.PHONY: tags critic
+
+tags:
+	ctags -f tags --recurse --totals \
+		--exclude=blib \
+		--exclude=.svn \
+		--exclude='*~' \
+		--languages=Perl --langmap=Perl:+.t \
+
+critic:
+	perlcritic -1 -q -profile perlcriticrc Timer.pm t/*.t
+
+MAKE_FRAG
+
+    return $postamble;
+}

Modified: branches/upstream/libtemplate-timer-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-timer-perl/current/README?rev=31709&op=diff
==============================================================================
--- branches/upstream/libtemplate-timer-perl/current/README (original)
+++ branches/upstream/libtemplate-timer-perl/current/README Sun Mar  8 15:14:53 2009
@@ -41,9 +41,14 @@
     make install
 
 
-COPYRIGHT AND LICENCE
+COPYRIGHT AND LICENSE
 
-Copyright (C) 2004 Andy Lester
+Copyright (C) 2004-2009 Andy Lester
 
 This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
+it under the terms of either the GNU Public License v3, or the Artistic
+License 2.0.
+
+    * http://www.gnu.org/copyleft/gpl.html
+
+    * http://www.opensource.org/licenses/artistic-license-2.0.php

Modified: branches/upstream/libtemplate-timer-perl/current/Timer.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-timer-perl/current/Timer.pm?rev=31709&op=diff
==============================================================================
--- branches/upstream/libtemplate-timer-perl/current/Timer.pm (original)
+++ branches/upstream/libtemplate-timer-perl/current/Timer.pm Sun Mar  8 15:14:53 2009
@@ -9,11 +9,11 @@
 
 =head1 VERSION
 
-Version 0.04
+Version 1.00
 
 =cut
 
-our $VERSION = '0.04';
+our $VERSION = '1.00';
 
 =head1 SYNOPSIS
 
@@ -23,10 +23,12 @@
 
 Using Template::Timer is simple.
 
+    use Template::Timer;
+
     my %config = ( # Whatever your config is
-        INCLUDE_PATH    => "/my/template/path",
-        COMPILE_EXT     => ".ttc",
-        COMPILE_DIR     => "/tmp/tt",
+        INCLUDE_PATH    => '/my/template/path',
+        COMPILE_EXT     => '.ttc',
+        COMPILE_DIR     => '/tmp/tt',
     );
 
     if ( $development_mode ) {
@@ -36,19 +38,19 @@
     my $template = Template->new( \%config );
 
 Now when you process templates, HTML comments will get embedded in your
-output, which you can easily grep for.
+output, which you can easily grep for.  The nesting level is also shown.
 
-    <!-- TIMER START: process mainmenu/mainmenu.ttml -->
-    <!-- TIMER START: include mainmenu/cssindex.tt -->
-    <!-- TIMER START: process mainmenu/cssindex.tt -->
-    <!-- TIMER END: process mainmenu/cssindex.tt (0.017279 seconds) -->
-    <!-- TIMER END: include mainmenu/cssindex.tt (0.017401 seconds) -->
+    <!-- TIMER START: L1 process mainmenu/mainmenu.ttml -->
+    <!-- TIMER START: L2 include mainmenu/cssindex.tt -->
+    <!-- TIMER START: L3 process mainmenu/cssindex.tt -->
+    <!-- TIMER END:   L3 process mainmenu/cssindex.tt (17.279 ms) -->
+    <!-- TIMER END:   L2 include mainmenu/cssindex.tt (17.401 ms) -->
 
     ....
 
-    <!-- TIMER END: process mainmenu/footer.tt (0.003016 seconds) -->
-    <!-- TIMER END: include mainmenu/footer.tt (0.003104 seconds) -->
-    <!-- TIMER END: process mainmenu/mainmenu.ttml (0.400409 seconds) -->
+    <!-- TIMER END:   L3 process mainmenu/footer.tt (3.016 ms) -->
+    <!-- TIMER END:   L2 include mainmenu/footer.tt (3.104 ms) -->
+    <!-- TIMER END:   L1 process mainmenu/mainmenu.ttml (400.409 ms) -->
 
 Note that since INCLUDE is a wrapper around PROCESS, calls to INCLUDEs
 will be doubled up, and slightly longer than the PROCESS call.
@@ -56,26 +58,67 @@
 =cut
 
 use base qw( Template::Context );
-use Time::HiRes (); # Save as much space as we can
+use Time::HiRes ();
+
+our $depth = 0;
+our $epoch = undef;
+our @totals;
 
 foreach my $sub ( qw( process include ) ) {
     no strict;
     my $super = __PACKAGE__->can("SUPER::$sub") or die;
-    *$sub = sub {
-        my $self     = shift;
-        my $template = ref $_[0] eq 'ARRAY'
-                            ? join( ' + ', @{$_[0]} )
-                            : ref $_[0] ? $_[0]->name : $_[0];
-        my $start    = [Time::HiRes::gettimeofday];
-        my $data     = $super->($self, @_);
-        my $elapsed  = Time::HiRes::tv_interval($start);
-        return <<"END"
-<!-- TIMER START: $sub $template -->
-$data
-<!-- TIMER END: $sub $template ($elapsed seconds) -->
-END
+    *{$sub} = sub {
+        my $self = shift;
+        my $what = shift;
+
+        my $template =
+            ref($what) eq 'ARRAY'
+                ? join( ' + ', @{$what} )
+                : ref($what)
+                    ? $what->name
+                    : $what;
+
+        my $level;
+        my $processed_data;
+        my $epoch_elapsed_start;
+        my $epoch_elapsed_end;
+        my $now   = [Time::HiRes::gettimeofday];
+        my $start = [@{$now}];
+        DOIT: {
+            local $epoch = $epoch ? $epoch : [@{$now}];
+            local $depth = $depth + 1;
+            $level = $depth;
+            $epoch_elapsed_start = _diff_disp($epoch);
+            $processed_data = $super->($self, $what, @_);
+            $epoch_elapsed_end = _diff_disp($epoch);
+        }
+        my $spacing = ' ' x $level;
+        my $level_elapsed = _diff_disp($start);
+        my $ip = uc substr( $sub, 0, 1 );
+        my $start_stats = "L$level $epoch_elapsed_start         $spacing$ip $template";
+        my $end_stats =   "L$level $epoch_elapsed_end $level_elapsed $spacing$ip $template";
+        @totals = ( $start_stats, @totals, $end_stats );
+        if ( $level > 1 ) {
+            return $processed_data;
+        }
+
+        my $summary = join( "\n",
+            '<!-- SUMMARY',
+            @totals,
+            '-->',
+            '',
+        );
+        @totals = ();
+        return "$processed_data\n$summary\n";
     }; # sub
 } # for
+
+
+sub _diff_disp {
+    my $starting_point = shift;
+
+    return sprintf( '%7.3f', Time::HiRes::tv_interval($starting_point) * 1000 );
+}
 
 
 =head1 AUTHOR
@@ -98,10 +141,13 @@
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright 2005 Andy Lester, All Rights Reserved.
+This library is free software; you can redistribute it and/or modify
+it under the terms of either the GNU Public License v3, or the Artistic
+License 2.0.
 
-This program is free software; you can redistribute it and/or modify it
-under the same terms as Perl itself.
+    * http://www.gnu.org/copyleft/gpl.html
+
+    * http://www.opensource.org/licenses/artistic-license-2.0.php
 
 =cut
 

Modified: branches/upstream/libtemplate-timer-perl/current/t/00-load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-timer-perl/current/t/00-load.t?rev=31709&op=diff
==============================================================================
--- branches/upstream/libtemplate-timer-perl/current/t/00-load.t (original)
+++ branches/upstream/libtemplate-timer-perl/current/t/00-load.t Sun Mar  8 15:14:53 2009
@@ -1,7 +1,12 @@
+#!perl
+
+use strict;
+use warnings;
+
 use Test::More tests => 1;
 
 BEGIN {
-use_ok( 'Template::Timer' );
+    use_ok( 'Template::Timer' );
 }
 
 diag( "Testing Template::Timer $Template::Timer::VERSION" );

Modified: branches/upstream/libtemplate-timer-perl/current/t/eval.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-timer-perl/current/t/eval.t?rev=31709&op=diff
==============================================================================
--- branches/upstream/libtemplate-timer-perl/current/t/eval.t (original)
+++ branches/upstream/libtemplate-timer-perl/current/t/eval.t Sun Mar  8 15:14:53 2009
@@ -3,7 +3,11 @@
 use strict;
 use warnings;
 
-use Test::More tests => 2;
+use Test::More tests => 3;
+
+BEGIN {
+    use_ok( 'Template' );
+}
 
 BEGIN {
     use_ok( 'Template::Timer' );
@@ -14,10 +18,10 @@
         CONTEXT => Template::Timer->new
     } );
 
-my $block = "[% thing = 'doohickey' %]";
+my $block = q{[% thing = 'doohickey' %]};
 
 TODO: { # See RT # 13225
-    local $TODO = "Problem identified but not fixed";
+    local $TODO = 'Problem identified but not fixed';
     my $rc = $tt->process( \*DATA, { block => $block } );
     ok( $rc, 'eval' );
 }

Modified: branches/upstream/libtemplate-timer-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtemplate-timer-perl/current/t/pod.t?rev=31709&op=diff
==============================================================================
--- branches/upstream/libtemplate-timer-perl/current/t/pod.t (original)
+++ branches/upstream/libtemplate-timer-perl/current/t/pod.t Sun Mar  8 15:14:53 2009
@@ -1,6 +1,9 @@
 #!perl -T
 
+use strict;
+use warnings;
+
 use Test::More;
-eval "use Test::Pod 1.14";
-plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+eval 'use Test::Pod 1.14';
+plan skip_all => 'Test::Pod 1.14 required for testing POD' if $@;
 all_pod_files_ok();




More information about the Pkg-perl-cvs-commits mailing list