Show
Ignore:
Timestamp:
02/14/08 22:31:01 (22 months ago)
Author:
bchoate
Message:

Initial work for performance logging.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-30/lib/MT/Template.pm

    r1369 r1372  
    9191    $tmpl->{include_path} = $param{path}; 
    9292    $tmpl->{include_filter} = $param{filter}; 
     93    $tmpl->{__file} = $file; 
    9394    my $contents = $tmpl->load_file($file); 
    9495    if (defined $contents) { 
     
    211212    $ctx ||= $tmpl->context; 
    212213 
     214    my ($timer, $start); 
     215    if (MT->config->PerformanceLogging) { 
     216        $timer = MT->get_timer(); 
     217    } 
     218    local $timer->{elapsed} = 0 if $timer; 
     219 
    213220    local $ctx->{__stash}{template} = $tmpl; 
    214221    my $tokens = $tmpl->tokens 
     
    243250        $ctx->var( 'page_columns', $columns ) if $columns; 
    244251    } 
    245     defined(my $res = $build->build($ctx, $tokens, $cond)) or 
     252 
     253    $timer->pause_partial if $timer; 
     254 
     255    my $res = $build->build($ctx, $tokens, $cond); 
     256 
     257    if ($timer) { 
     258        $timer->mark("MT::Template::build[" . ($tmpl->name || $tmpl->{__file}).']'); 
     259    } 
     260 
     261    unless (defined($res)) { 
    246262        return $tmpl->error(MT->translate( 
    247263            "Publish error in template '[_1]': [_2]", 
    248264            $tmpl->name || $tmpl->{__file}, $build->errstr)); 
     265    } 
    249266    $res =~ s/^\s*//; 
    250267    return $res;