Ignore:
Timestamp:
2013-12-18T11:08:13+13:00 (10 years ago)
Author:
jmt12
Message:

Adding microtiming... a little tricky what with TDBServer taking forever to shut down, but I've added the 'duration calculation' in the END block, so it should get all the time appropriately

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/parallel-building/trunk/src/perllib/parallelbuildinginexport.pm

    r28654 r28770  
    3838# Randomize the order of files in the filelist
    3939use List::Util qw( shuffle );
     40use Time::HiRes  qw( gettimeofday tv_interval );
    4041
    4142# Greenstone Modules
     
    4344use inexport;
    4445
     46our $start_time;
     47
    4548BEGIN
    4649{
    4750  @parallelbuildinginexport::ISA = ('inexport');
     51}
     52
     53END
     54{
     55  if (defined $start_time)
     56  {
     57    my $end_time = [&gettimeofday()];
     58    my $duration = tv_interval($start_time, $end_time);
     59    print '  Duration: ' . sprintf('%0.6f', $duration) . "\n";
     60  }
    4861}
    4962
     
    8497                ];
    8598
     99
    86100# @function new()
    87101# Constructor
     
    92106  my $self = new inexport(@_);
    93107
    94   # Legacy support
     108  $start_time = [&gettimeofday()];
     109
     110  # Legacy support - Dr Suleman initially had different names for these
     111  # arguments, namely jobs and epoch
    95112  if ($self->{'workers'} eq '' && $self->{'jobs'} ne '')
    96113  {
     
    105122  if ($self->{'batchsize'} !~ /^\d+$/)
    106123  {
    107     print STDERR "WARNING: batchsize missing or not a number - assuming batchsize = 1\n";
     124    print STDERR "Warning! Batchsize missing or not a number - assuming batchsize = 1\n";
    108125    $self->{'batchsize'} = 1;
    109126  }
    110127  if ($self->{'workers'} !~ /^\d+$/ || $self->{'workers'} < 1)
    111128  {
    112     print STDERR "WARNING: parallel processing not available with fewer than one worker - assuming serial import\n";
     129    print STDERR "Warning! Parallel processing not available with fewer than one worker - assuming serial import\n";
    113130    $self->{'workers'} = 0;
    114131  }
    115132  else
    116133  {
    117     print "Performing Parallel Import: workers:" . $self->{'workers'} . ", batchsize:" . $self->{'batchsize'} . "\n";
     134    my $message = 'Performing Parallel Import';
     135    print &makeHeader($message) . "\n";
     136    print '  Started:   ' . @{$start_time}[0] . '.' . @{$start_time}[1] . "\n";
     137    print '  Workers:   ' . $self->{'workers'} . "\n";
     138    print '  Batchsize: ' . $self->{'batchsize'} . "\n";
     139    print '=' x 79 . "\n";
    118140    if (!$self->{'removeold'})
    119141    {
     
    127149}
    128150# new()
     151
     152
     153## @function deinit()
     154
    129155
    130156# @function _farmOutProcesses()
     
    210236# _farmOutProcesses()
    211237
    212 # @function getSupportedArguments
     238
     239## @function getSupportedArguments()
     240#
    213241# Retrieve the list of arguments that are specific to this subclass of inexport
    214 # so they can be added to the list of supported arguments to import.pl. The
    215 # use of any of these arguments automatically causes this subclass to be
     242# so they can be added to the list of supported arguments to import.pl. The use
     243# of any of these arguments automatically causes this subclass to be
    216244# instantiated and used in preference to the parent class. ATM it is up to the
    217245# implementer to ensure these arguments are unique.
     246#
    218247sub getSupportedArguments
    219248{
    220249  return $arguments;
    221250}
    222 # getSupportedArguments()
     251## getSupportedArguments() ##
     252
    223253
    224254################################################################################
     
    312342
    313343
     344## @function makeHeader($msg, [$length])
     345#
     346# Create a centered header string given a certain message padded with '=' characters.
     347#
     348# @param $msg The message to center as a string
     349# @param $length The desired length of string - defaults to 79
     350# @return A string centered with '=' as padding
     351#
     352sub makeHeader
     353{
     354  my ($msg, $length) = @_;
     355  if (!defined $length)
     356  {
     357    $length = 79; # 80 with newline
     358  }
     359  my $filler_length = ($length - 2 - length($msg)) / 2;
     360  my $filler = '=' x $filler_length;
     361  if (length($msg) % 2 == 0)
     362  {
     363    $msg = $filler . ' ' . $msg . ' =' . $filler;
     364  }
     365  else
     366  {
     367    $msg = $filler . ' ' . $msg . ' ' . $filler;
     368  }
     369  return $msg;
     370}
     371## makeHeader() ##
    3143721;
Note: See TracChangeset for help on using the changeset viewer.