use strict; use warnings; use Benchmark;# use threads; #open(PROD,"/ms/user/j/juyva/dev/files_xls_tmpl_cfg_nonscripts/prod.txt") || die " $! "; #my @allProd = ; #close PROD; #open(TEST,"/ms/user/j/juyva/dev/files_xls_tmpl_cfg_nonscripts/test.txt") || die " $! "; #my @allTest = ; #close TEST; my @allPort = qw(22600 22610); my %hashOp; sub boss { for(my $i = 0;$i < @allPort; $i++) { my $thr = threads->new(\&worker,$allPort[$i]); } foreach my $thr (threads->list) { # Don't join the main thread or ourselves if ($thr->tid && !threads::equal($thr, threads->self)) { $thr->join; } } } sub worker { my $port = shift; my $timeTakenDm = timeit(1,sub { system(" /ms/dist/pcs/bin/client hqsas501 $port 200 \-f /ms/user/j/juyva/dev/files_xls_tmpl_cfg_nonscripts/sql1.clmod.NEW.txt > $port.txt " )}); print "Dm took:",timestr($timeTakenDm),"\n"; if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without'; } else { printf "child exited with value %d\n", $? >> 8; } } my $obj = timeit(1, sub { my $thrboss = threads->new(\&boss); $thrboss->join; my (@allProd,@allTest); foreach my $port (@allPort) { open(HAN,"$port.txt") || die " $!"; my @temp = ; $hashOp{$port} = \@temp; #print $hashOp{$port}; close HAN; } my $timeSort = timeit(1, sub { @allProd = sort @{$hashOp{"22600"}}; @allTest = sort @{$hashOp{"22610"}}; }); print "sort took:",timestr($timeSort),"\n"; #my @allProd = sort @{$hashOp{"22600"}}; #my @allTest = sort @{$hashOp{"22610"}}; #print @allProd; #print @allTest; unless(@allProd == @allTest) { print " inside unequal rows retunred\n"; my $whichhasmoreelements = @allProd > @allTest ? 'allProd' : 'allTest'; if($whichhasmoreelements =~ /Prod/) { print " the no of lines do not match prod has more rows are they are \n"; my @tempallProd = @allProd; my @diffProdTest = splice(@tempallProd,(@allTest -1),(@allProd - @allTest)); print @diffProdTest; print " do u want to continue : enter y/n "; my $choice = ; exit if($choice =~ /^n$/i); } else { print " the no of lines do not match test has more rows are they are \n"; my @tempallTest = @allTest; my @diffProdTest = splice(@tempallTest,(@allProd - 1),(@allTest - @allProd)); print @diffProdTest; print " do u want to continue : enter y/n "; my $choice = ; print " $choice "; exit if($choice =~ /^n$/i); } } for( my $i = 0;$i < (@allProd > @allTest ? @allProd : @allTest); $i++) { unless($allProd[$i] eq $allTest[$i]) { my @defaultProd = split/\|/,$allProd[$i]; my @defaultTest = split/\|/,$allTest[$i]; unless(@defaultProd == @defaultTest) { my $whichhasmoreelements = @defaultProd > @defaultTest ? 'defaultProd' : 'defaultTest'; if($whichhasmoreelements =~ /Prod/) { print " the no of lines do not match prod has more rows are they are \n"; my @tempallProd = @defaultProd; my @diffProdTest = splice(@tempallProd,(@defaultTest -1),(@defaultProd - @defaultTest)); print @diffProdTest; print " do u want to continue : enter y/n "; my $choice = ; exit if($choice =~ /^n$/i); } else { print " the no of lines do not match test has more rows are they are \n"; my @tempallTest = @defaultTest; my @diffProdTest = splice(@tempallTest,(@defaultProd - 1),(@defaultTest - @defaultProd)); print @diffProdTest; print " do u want to continue : enter y/n "; my $choice = ; print " $choice "; exit if($choice =~ /^n$/i); } } for( my $a = 0;$a < (@defaultProd > @defaultTest ? @defaultProd : @defaultTest); $a++) { unless($defaultProd[$a] eq $defaultTest[$a]) { print " Column $a differs::"; print " PROD value $defaultProd[$a] : TEST value $defaultTest[$a] \n"; } } } } } ); print "code took:",timestr($obj),"\n";