- Timestamp:
- 2013-12-18T11:08:13+13:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/parallel-building/trunk/src/perllib/parallelbuildinginexport.pm
r28654 r28770 38 38 # Randomize the order of files in the filelist 39 39 use List::Util qw( shuffle ); 40 use Time::HiRes qw( gettimeofday tv_interval ); 40 41 41 42 # Greenstone Modules … … 43 44 use inexport; 44 45 46 our $start_time; 47 45 48 BEGIN 46 49 { 47 50 @parallelbuildinginexport::ISA = ('inexport'); 51 } 52 53 END 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 } 48 61 } 49 62 … … 84 97 ]; 85 98 99 86 100 # @function new() 87 101 # Constructor … … 92 106 my $self = new inexport(@_); 93 107 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 95 112 if ($self->{'workers'} eq '' && $self->{'jobs'} ne '') 96 113 { … … 105 122 if ($self->{'batchsize'} !~ /^\d+$/) 106 123 { 107 print STDERR "W ARNING: batchsize missing or not a number - assuming batchsize = 1\n";124 print STDERR "Warning! Batchsize missing or not a number - assuming batchsize = 1\n"; 108 125 $self->{'batchsize'} = 1; 109 126 } 110 127 if ($self->{'workers'} !~ /^\d+$/ || $self->{'workers'} < 1) 111 128 { 112 print STDERR "W ARNING: 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"; 113 130 $self->{'workers'} = 0; 114 131 } 115 132 else 116 133 { 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"; 118 140 if (!$self->{'removeold'}) 119 141 { … … 127 149 } 128 150 # new() 151 152 153 ## @function deinit() 154 129 155 130 156 # @function _farmOutProcesses() … … 210 236 # _farmOutProcesses() 211 237 212 # @function getSupportedArguments 238 239 ## @function getSupportedArguments() 240 # 213 241 # 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 # useof any of these arguments automatically causes this subclass to be242 # 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 216 244 # instantiated and used in preference to the parent class. ATM it is up to the 217 245 # implementer to ensure these arguments are unique. 246 # 218 247 sub getSupportedArguments 219 248 { 220 249 return $arguments; 221 250 } 222 # getSupportedArguments() 251 ## getSupportedArguments() ## 252 223 253 224 254 ################################################################################ … … 312 342 313 343 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 # 352 sub 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() ## 314 372 1;
Note:
See TracChangeset
for help on using the changeset viewer.