Skip to content

Commit

Permalink
Item12022: avoid parseTime in PF logger _rotate()
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/branches/Release01x01@15249 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
PaulHarvey authored and PaulHarvey committed Aug 1, 2012
1 parent 24f4015 commit 57d3d13
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions core/lib/Foswiki/Logger/PlainFile.pm
Original file line number Diff line number Diff line change
Expand Up @@ -329,18 +329,26 @@ sub _rotate {
if (TRACE);
next;
}
my $eventTime = Foswiki::Time::parseTime( $event[1] );

if ( !$eventTime ) {
#Item12022: parseTime bogs the CPU down here, so try a dumb regex first
# (assuming ISO8601 format Eg. 2000-01-31T23:59:00Z). Result: 4x speedup
my $eventMonth;
if ( $event[1] =~ /^(\d{4})-(\d{2})-\d{2}T[0-9:]+Z\b/ ) {
$eventMonth = $1 . $2;
}
else {
print STDERR ">> Non-ISO date string encountered\n" if (TRACE);
$eventMonth = _time2month( Foswiki::Time::parseTime( $event[1] ) );
}

if ( !defined $eventMonth ) {

print STDERR
">> Bad time in log - skip: $line - line $linecount in $log\n"
if (TRACE);
next;
}

my $eventMonth = _time2month($eventTime);

if ( $eventMonth < $curMonth ) {
push( @{ $months{$eventMonth} }, $stashline );
$stashline = '';
Expand Down

0 comments on commit 57d3d13

Please sign in to comment.