i have a timestamp log file and i need to perform some performance benchmarking. however i am not able to find a way ,it's a programming problem ;really sorry for the long question
here is the log file
DATE time,unique ID ,Message
2014-05-29 10:22:21,880,165ab6a8-e736-11e3-8748-8d365226be24,TP Servic
+e Request
2014-05-29 10:22:21,962,165ab6a8-e736-11e3-8748-8d365226be24,ProcessNa
+me: TC
2014-05-29 10:22:21,965,165ab6a8-e736-11e3-8748-8d365226be24,P5 Starte
+d
2014-05-29 10:22:21,965,165ab6a8-e736-11e3-8748-8d365226be24,ProcessNa
+me: SL
2014-05-29 10:22:21,968,165ab6a8-e736-11e3-8748-8d365226be24,Process M
+essage :PreProcess
2014-05-29 10:22:21,969,165ab6a8-e736-11e3-8748-8d365226be24,Input Mes
+sage to P5
2014-05-29 10:22:22,159,165ab6a8-e736-11e3-8748-8d365226be24,ProcessNa
+me: PP
2014-05-29 10:22:22,170,165ab6a8-e736-11e3-8748-8d365226be24,Process M
+essage :ValidationAndCompliance
2014-05-29 10:22:22,174,165ab6a8-e736-11e3-8748-8d365226be24,Input Mes
+sage to P5
2014-05-29 10:22:58,488,165ab6a8-e736-11e3-8748-8d365226be24,ProcessNa
+me: VC
2014-05-29 10:22:58,493,165ab6a8-e736-11e3-8748-8d365226be24,Process M
+essage :TranslateAndLoad
2014-05-29 10:22:58,493,165ab6a8-e736-11e3-8748-8d365226be24,Input Mes
+sage to P5
2014-05-29 10:23:08,301,165ab6a8-e736-11e3-8748-8d365226be24,ProcessNa
+me: TL
2014-05-29 10:23:08,306,165ab6a8-e736-11e3-8748-8d365226be24,P5 Move r
+equest
2014-05-29 07:12:15,966,1770ebca-e722-11e3-b793-c6903cc19f13,P5 Starte
+d
2014-05-29 07:12:15,966,1770ebca-e722-11e3-b793-c6903cc19f13,ProcessNa
+me: SL
2014-05-29 07:12:16,644,1770ebca-e722-11e3-b793-c6903cc19f13,Process M
+essage :PreProcess
2014-05-29 07:12:16,644,1770ebca-e722-11e3-b793-c6903cc19f13,Input Mes
+sage to P5
2014-05-29 07:12:16,923,1770ebca-e722-11e3-b793-c6903cc19f13,ProcessNa
+me: PP
2014-05-29 07:12:17,730,1770ebca-e722-11e3-b793-c6903cc19f13,Process M
+essage :TranslateAndLoad
2014-05-29 07:12:17,731,1770ebca-e722-11e3-b793-c6903cc19f13,Input Mes
+sage to P5
2014-05-29 07:14:03,187,1770ebca-e722-11e3-b793-c6903cc19f13,ProcessNa
+me: TL
2014-05-29 07:14:04,048,1770ebca-e722-11e3-b793-c6903cc19f13,P5 Move r
+equest
here's is what i want to do ,i need to find
1. Total time : btw P5 move request and TP service request; however sometimes some messages might not be present like u can see for second unique id above(it does'nt have TP service request)
2. Process time :for each process like TC,SL,PP,VC,TL ; i need to find time till i encounter something like P5 Started
|| input message to p5 || p5 move request. eg like for the first id 165ab6a8-e736-11e3-8748-8d365226be24
TC -> p5 started+ SL -> input+PP -> input + VC -> input+ TAL -> p5 move request
i've written some code ;but i cant seem to find a way to solve the 2nd process time summation problem
use warnings;
#read the file (PLEASE PROVIDE INPUT FILE PATH)
open(hanr,"D:/Process_debug.txt")or die"error $!\n";
#digesting the lines
@lines = <hanr>;
open (hanw,">D:/process_time.txt") or die("error:cannot create $! \n")
+;
for $value2 (@lines) {
my @lines2 = split(/,/,$value2);
my $datetime = $lines2[0];
my $ms = $lines2[1];
my $inid = $lines2[2];
my $message = $lines2[3];
sub gettime($);
if($message eq "TP Service Request"){
$date = substr $datetime,11;
@timearray = split (/:/,$date);
$hours = $timearray[0];
$minutes = $timearray[1];
$seconds = $timearray[2];
$hours = $hours*60*60*1000;
$minutes = $minutes*60*1000;
$seconds = $seconds*1000;
$totaltimeinms = $hours+$minutes+$seconds+$ms;
$time1 = $totaltimeinms;
}
if($message eq "P5 Move request" ){
$date = substr $datetime,11;
@timearray = split (/:/,$date);
$hours = $timearray[0];
$minutes = $timearray[1];
$seconds = $timearray[2];
$hours = $hours*60*60*1000;
$minutes = $minutes*60*1000;
$seconds = $seconds*1000;
$totaltimeinms2 = $hours+$minutes+$seconds+$ms;
$time2 = $totaltimeinms2;
}
print timefile "DATA : $time1 && $time2\n";
if ($time1 && $time2){
$finaltime = $time2-$time1;
print timefile "$inid took : $finaltime \n";
last;
}
}
close hanw;
close hanr;
output file could be like unique id :total time = 100 ms and process time = 30 ms;