Hi again,
I'm using version 5.8.4, so hopefully I'm not experiencing a bug in Perl.
I'm trying to find a way of doing a hash that retains its order. I've looked on CPAN as you suggested, but both Tie::Hash::Indexed and Tie::InsertOrderHash which look suitable require compilation, and I was hoping to find something that could be copied from one platform to the other without any additional work (we have an old Python script which is very easy to use, and I want to at least equal that in terms of ease of use).
As for your final point about whether this is a worth while exercise, I have been told that it is as we need to be able to be able to compare our system when running on machines with different processors and operating systems, so issues like scheduling etc are one of the variables we need to look at. Hopefully by running the test many times we can get an average figure which reflects platform performance reasonably well.
I've given up on using batch files - they were worse than our script interpreter, as they were crashing the command prompt window (isn't Windows great). I'm now running some tiny exes I've just compiled in C that just printf() a character but the script still hangs. Here's the script so far:
use Acme::Comment type => 'C++', own_line => 1, one_line => 1; use Cwd; use Run; use Config; use Data::Dumper; use threads; //use Async; use Benchmark qw(:all); use strict; use warnings; # Change this structure accordingly... my %allScripts = ( submitters => { numRuns => 4, steps => ["print1.exe", "print2.exe"] }, reviewers => { numRuns => 1, steps => ["printA.exe", "printB.exe"] } ); my $numCompleteTestRuns = 4; my $mscriptInterpreter = "ScriptRunner.exe"; my $currentDir = getcwd(); eval{timethis($numCompleteTestRuns, 'runTests')}; warn $@ if $@; sub runTests { print "Waiting to spawn processes.\n"; foreach my $userType (sort {$allScripts{$a} <=> $allScripts{$b}} k +eys %allScripts) { // print Dumper($allScripts{$userType}{steps}); print "\nThe $userType will run $allScripts{$userType}{numRuns +} times. The steps are:\n"; foreach my $i (0 .. $#{ $allScripts{$userType}{steps}}) { print "$i = $allScripts{$userType}{steps}[$i]\n"; } } print("\n\n"); my @threadList = (); # key-value pairs in a Perl hash are not always stored in the orde +r in which they were defined! // foreach my $userType (keys %allScripts) foreach my $userType (sort {$allScripts{$a} <=> $allScripts{$b}} k +eys %allScripts) { for my $i (0 .. $allScripts{$userType}{numRuns}) { print "\nAbout to create $userType thread $i:\n"; my $thread = threads->new(\&stepThread, \$allScripts{$user +Type}); push (@threadList, $thread); } } my $numThreads = $#threadList + 1; print("There are $numThreads threads\n\n"); # wait for each running thread to end foreach my $thread (@threadList) { $thread->join; print("A thread joined\n\n"); } print "Processes ended - Goodbye.\n"; } # thread runs a type of users steps once only sub stepThread { print("starting thread\n\n"); my $currentUsertype = shift; // print Dumper(${$currentUsertype}->{steps}); foreach my $i (0 .. $#{${$currentUsertype}->{steps}}) { my $fileName = ${$currentUsertype}->{steps}[$i]; // my $command = $mscriptInterpreter . " \"" . $currentDir . "/ +" . $fileName . "\"\n"; my $command = $fileName . "\"\n"; print("About to run: $fileName\n"); my $time0 = new Benchmark; my $output = `$command`; my $time1 = new Benchmark; my $timeTaken = timestr(timediff($time1, $time0)); my $printOutput = "******** BEGIN $fileName output ********\n$ +output\n******** END $fileName output (time taken: $timeTaken) ****** +**\n"; print($printOutput); } print("Ending thread\n\n"); }
In reply to Re^4: "Thread already joined at..." and "A thread exited while x threads were running" errors
by nickos
in thread "Thread already joined at..." and "A thread exited while x threads were running" errors
by nickos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |