edimusrex has asked for the wisdom of the Perl Monks concerning the following question:

I am using Parallel::ForkManager to test a webservice. The most important piece of information I need is how long each fork took to process the request. Here is a sample of my code

#!/usr/bin/perl use warnings; use strict; use File::Basename; use diagnostics; use Parallel::ForkManager qw( ); use Time::HiRes qw( time ); my $max_processes = 5; my $home = '/vagrant'; my $url = ''; my @files = `ls $home/*.zip`; my $pm = Parallel::ForkManager->new($max_processes); foreach my $zip (@files){ chomp $zip; my $start = time(); my $pid = $pm->start and next; my $filename = `unzip -l $zip | awk '{print \$4}' | grep -P '.*-\\ +d+\\.xml'`; chomp $filename; my $header = "curl -s --header 'Content-Type: application/zip' --d +ata-binary '@" . $zip . "' '". $url . $filename . '&media' . "=xml'"; my @response = `$header`; foreach my $line (@response){ chomp $line; if ($line =~ m/\<ref href\=\"(.*-\d+\.xml)\"\/\>\<\/entry\>/){ print "XBRL Name -- $1\nExpected Filename -- $filename\n"; last; } } my $end = time(); print "Runtime --- "; printf("%.2f\n", $end - $start); print "\n\n"; $pm->finish; } $pm->wait_all_children;

The output of the runtime is incorrect as it seems like the start time is not processed for each item in my array. There must be a better way to do it but damned if I know. Your help would be greatly appreciated