Browse Source

move elapsed rendering time into bin/wrt-render-all

main
Brennen Bearnes 5 years ago
parent
commit
cf9ccc7361
3 changed files with 14 additions and 11 deletions
  1. +7
    -0
      bin/wrt-render-all
  2. +0
    -9
      lib/App/WRT/Renderer.pm
  3. +7
    -2
      t/bin-wrt-render-all.t

+ 7
- 0
bin/wrt-render-all View File

@ -42,10 +42,13 @@ no warnings 'uninitialized';
use Getopt::Long;
use Pod::Usage;
use Time::HiRes;
use App::WRT;
use App::WRT::FileIO;
use App::WRT::Renderer;
my $start_time = [Time::HiRes::gettimeofday()];
# If invoked directly from the command-line, caller() will return undef.
# Execute main() with a callback to print output directly, a FileIO object,
# and a copy of our real @ARGV:
@ -88,6 +91,10 @@ sub main {
);
$renderer->render();
$output->(
"elapsed: " . Time::HiRes::tv_interval($start_time) . " seconds"
);
}
1;

+ 0
- 9
lib/App/WRT/Renderer.pm View File

@ -6,7 +6,6 @@ use 5.10.0;
use Carp;
use File::Basename;
use Time::HiRes;
=pod
@ -82,9 +81,6 @@ sub render {
my $entry_dir = $self->{wrt}->{entry_dir};
my $publish_dir = $self->{wrt}->{publish_dir};
# Use this to log elapsed render time:
my $start_time = [Time::HiRes::gettimeofday()];
# Ensure that publication path exists and is a directory:
if (-e $publish_dir) {
unless (-d $publish_dir) {
@ -145,11 +141,6 @@ sub render {
$self->log("rendered $rendered_count entries");
$self->log("copied $copied_count static files");
$self->log(
" in "
. Time::HiRes::tv_interval($start_time)
. " seconds"
);
# Presumed success:
return 1;


+ 7
- 2
t/bin-wrt-render-all.t View File

@ -8,7 +8,7 @@ use 5.10.0;
use lib 'lib';
use Encode;
use Test::More tests => 2;
use Test::More tests => 3;
use App::WRT::Mock::FileIO;
chdir 'example';
@ -25,6 +25,11 @@ my @local_argv = ();
main($output, $mock_io, @local_argv);
ok(
$output_string =~ 'rendered 22 entries',
$output_string =~ 'rendered 23 entries',
'rendered expected number of entries'
) or diag($output_string);
ok(
$output_string =~ 'seconds',
'log mentions seconds'
) or diag($output_string);

|||||||
x
 
000:0
Loading…
Cancel
Save