diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-09-09 15:44:33 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-09-09 15:45:11 +0200 |
commit | 1bedc13c66dd5a551e3e6e90b6df55002c7ded77 (patch) | |
tree | dd8e5e7f5449b8c824972af7cc30d332adbf2084 /lib | |
parent | efe11290ae3c71d2a7a3735c265ff22a0cf92921 (diff) | |
download | App-BorgRestore-1bedc13c66dd5a551e3e6e90b6df55002c7ded77.tar.gz App-BorgRestore-1bedc13c66dd5a551e3e6e90b6df55002c7ded77.tar.xz |
PathTimeTable/DB: Use constant to control trace logging
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/App/BorgRestore/PathTimeTable/DB.pm | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/App/BorgRestore/PathTimeTable/DB.pm b/lib/App/BorgRestore/PathTimeTable/DB.pm index b0c0bb8..d514f0c 100644 --- a/lib/App/BorgRestore/PathTimeTable/DB.pm +++ b/lib/App/BorgRestore/PathTimeTable/DB.pm @@ -22,6 +22,10 @@ directory is added, the previous cache is invalidated. =cut +# Trace logging statements are disabled here since they incur a performance +# overhead because they are in tight loops. Change to 1 when necessary. +use constant TRACE => 0; + method new($class: $deps = {}) { return $class->new_no_defaults($deps); } @@ -59,9 +63,7 @@ method add_path($path, $time) { $self->_add_path_to_db($self->{archive_id}, $path, $time); my $cached = $self->{cache}->{$path}; if ($path ne $full_path && (!defined $cached || $cached < $time)) { - # logging statements are commented since they incur a performance - # overhead because they are called very often. Uncomment when necessary - #$log->tracef("Setting cache time for path '%s' to %d", $path, $time); + $log->tracef("Setting cache time for path '%s' to %d", $path, $time) if TRACE; $self->{cache}->{$path} = $time; } $path = substr($path, 0, $slash_index); @@ -69,7 +71,7 @@ method add_path($path, $time) { $self->_add_path_to_db($self->{archive_id}, $path, $time) unless $path eq "."; my $cached = $self->{cache}->{$path}; if ($path ne $full_path && (!defined $cached || $cached < $time)) { - #$log->tracef("Setting cache time for path '%s' to %d", $path, $time); + $log->tracef("Setting cache time for path '%s' to %d", $path, $time) if TRACE; $self->{cache}->{$path} = $time; } $self->{current_path_in_cache} = $full_path; @@ -79,11 +81,11 @@ method _add_path_to_db($archive_id, $path,$time) { my $cached = $self->{cache}->{$path}; $self->{stats}->{total_potential_calls_to_db_class}++; if (!defined $cached || $cached < $time) { - #$log->tracef("Updating DB for path '%s' with time %d", $path, $time); + $log->tracef("Updating DB for path '%s' with time %d", $path, $time) if TRACE; $self->{stats}->{real_calls_to_db_class}++; $self->{deps}->{db}->update_path_if_greater($archive_id, $path, $time); } else { - #$log->tracef("Skipping DB update for path '%s' because (cached) DB time is %d and file time is %d which is lower", $path, $cached, $time); + $log->tracef("Skipping DB update for path '%s' because (cached) DB time is %d and file time is %d which is lower", $path, $cached, $time) if TRACE; } } |