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/WeblogPublisher.pm

    r1365 r1372  
    12101210    my ( $blog, $root_path, $map, $at, $ctx, $cond, $build_static, %specifier ) 
    12111211      = @_; 
     1212 
    12121213    my $finfo; 
    12131214    my $archiver = $mt->archiver($at); 
     
    14081409    return 1 if ( $tmpl->build_dynamic ); 
    14091410    return 1 if ( $entry && $entry->status != MT::Entry::RELEASE() ); 
     1411 
     1412    my $timer = MT->get_timer; 
     1413    if ($timer) { 
     1414        $timer->pause_partial; 
     1415    } 
     1416    local $timer->{elapsed} = 0 if $timer; 
    14101417 
    14111418    if ( 
     
    14511458 
    14521459        $html = $tmpl->build( $ctx, $cond ); 
    1453         defined($html) 
    1454           or return $mt->error( 
     1460        unless (defined($html)) { 
     1461            $timer->unpause if $timer; 
     1462            return $mt->error( 
    14551463            ( 
    14561464                $category ? MT->translate( 
     
    14731481            ) 
    14741482          ); 
     1483        } 
    14751484        my $orig_html = $html; 
    14761485        MT->run_callbacks( 
     
    15061515        ## changed. If not, we won't update the published 
    15071516        ## file, so as not to modify the mtime. 
    1508         return 1 unless $fmgr->content_is_updated( $file, \$html ); 
     1517        unless ($fmgr->content_is_updated( $file, \$html )) { 
     1518            $timer->unpause if $timer; 
     1519            return 1; 
     1520        } 
    15091521 
    15101522        ## Determine if we need to build directory structure, 
     
    15161528          unless $path eq '/'; ## OS X doesn't like / at the end in mkdir(). 
    15171529        unless ( $fmgr->exists($path) ) { 
    1518             $fmgr->mkpath($path) 
    1519               or return $mt->trans_error( "Error making path '[_1]': [_2]", 
    1520                 $path, $fmgr->errstr ); 
     1530            if (!$fmgr->mkpath($path)) { 
     1531                $timer->unpause if $timer; 
     1532                return $mt->trans_error( "Error making path '[_1]': [_2]", 
     1533                    $path, $fmgr->errstr ); 
     1534            } 
    15211535        } 
    15221536 
     
    15281542        my $use_temp_files = !$mt->{NoTempFiles}; 
    15291543        my $temp_file = $use_temp_files ? "$file.new" : $file; 
    1530         defined( $fmgr->put_data( $html, $temp_file ) ) 
    1531           or return $mt->trans_error( "Writing to '[_1]' failed: [_2]", 
    1532             $temp_file, $fmgr->errstr ); 
     1544        unless ( defined $fmgr->put_data( $html, $temp_file ) ) { 
     1545            $timer->unpause if $timer; 
     1546            return $mt->trans_error( "Writing to '[_1]' failed: [_2]", 
     1547                $temp_file, $fmgr->errstr ); 
     1548        } 
    15331549        if ($use_temp_files) { 
    1534             $fmgr->rename( $temp_file, $file ) 
    1535               or return $mt->trans_error( 
    1536                 "Renaming tempfile '[_1]' failed: [_2]", 
    1537                 $temp_file, $fmgr->errstr ); 
     1550            if (!$fmgr->rename( $temp_file, $file )) { 
     1551                $timer->unpause if $timer; 
     1552                return $mt->trans_error( 
     1553                    "Renaming tempfile '[_1]' failed: [_2]", 
     1554                    $temp_file, $fmgr->errstr ); 
     1555            } 
    15381556        } 
    15391557        MT->run_callbacks( 
     
    15681586 
    15691587    } 
     1588    $timer->mark("total:rebuild_file[template_id:" . $tmpl->id . "]") 
     1589        if $timer; 
    15701590    1; 
    15711591} 
     
    16891709            $finfo->save(); 
    16901710        } 
     1711 
     1712        my $timer = MT->get_timer; 
     1713        if ($timer) { 
     1714            $timer->pause_partial; 
     1715        } 
     1716        local $timer->{elapsed} = 0 if $timer; 
    16911717 
    16921718        my $ctx = MT::Template::Context->new; 
     
    17151741 
    17161742        my $html = $tmpl->build($ctx); 
    1717         return $mt->error( $tmpl->errstr ) unless defined $html; 
     1743        unless (defined $html) { 
     1744            $timer->unpause if $timer; 
     1745            return $mt->error( $tmpl->errstr ); 
     1746        } 
    17181747 
    17191748        my $orig_html = $html; 
     
    17521781          unless $path eq '/';    ## OS X doesn't like / at the end in mkdir(). 
    17531782        unless ( $fmgr->exists($path) ) { 
    1754             $fmgr->mkpath($path) 
    1755               or return $mt->trans_error( "Error making path '[_1]': [_2]", 
    1756                 $path, $fmgr->errstr ); 
     1783            if (! $fmgr->mkpath($path) ) { 
     1784                $timer->unpause if $timer; 
     1785                return $mt->trans_error( "Error making path '[_1]': [_2]", 
     1786                    $path, $fmgr->errstr ); 
     1787            } 
    17571788        } 
    17581789 
     
    17601791        my $use_temp_files = !$mt->{NoTempFiles}; 
    17611792        my $temp_file = $use_temp_files ? "$file.new" : $file; 
    1762         defined( $fmgr->put_data( $html, $temp_file ) ) 
    1763           or return $mt->trans_error( "Writing to '[_1]' failed: [_2]", 
    1764             $temp_file, $fmgr->errstr ); 
     1793        unless (defined( $fmgr->put_data( $html, $temp_file ) )) { 
     1794            $timer->unpause if $timer; 
     1795            return $mt->trans_error( "Writing to '[_1]' failed: [_2]", 
     1796                $temp_file, $fmgr->errstr ); 
     1797        } 
    17651798        if ($use_temp_files) { 
    1766             $fmgr->rename( $temp_file, $file ) 
    1767               or 
    1768               return $mt->trans_error( "Renaming tempfile '[_1]' failed: [_2]", 
    1769                 $temp_file, $fmgr->errstr ); 
     1799            if (!$fmgr->rename( $temp_file, $file )) { 
     1800                $timer->unpause if $timer; 
     1801                return $mt->trans_error( "Renaming tempfile '[_1]' failed: [_2]", 
     1802                    $temp_file, $fmgr->errstr ); 
     1803            } 
    17701804        } 
    17711805        MT->run_callbacks( 
     
    17901824            file         => $file 
    17911825        ); 
     1826 
     1827        $timer->mark("total:rebuild_indexes[template_id:" . $tmpl->id . ";file:$file]") 
     1828            if $timer; 
    17921829    } 
    17931830    1;