I am trying to calculate avg response time on hourly basis from the log file which has millions of records.
As of now I am trying with creating temp file which will have lines with unique id and start time and end time and after that another script will run on this temp file to calcualte avg response time.
Reason I posted this ques in forum becuase this way takes more than an hour to create temp file.
Is there any way we can do it quicker?
Note:These UNIQID is not coming in sequence.
for uid in ${uids}; do
count=`grep "$uid" test.log|wc -l`
if [ "${count}" -ne "0" ]; then
unique_uids[counter]="$uid"
#echo "${unique_uids[counter]}"
let counter=counter+1
fi
done
echo ${unique_uids[@]}
echo $counter
echo " Unique No:" ${#unique_uids[@]}
echo uid StartTime EndTime" > $log
for unique_uids in ${unique_uids[@]} ; do
responseTime=`cat $i|grep "${unique_uids}" |awk '{split($2,Arr,":|,"); print Arr[1]*3600000+Arr[2]*60000+Arr[3]*1000+Arr[4]}'|sort -n`
echo $unique_uids $responseTime >> $log
done
Output will be like this
UID Start time end time
UNIQID1 13:04:19,324 13:04:20,120
---------- Post updated at 07:12 AM ---------- Previous update was at 05:33 AM ----------
pls let me know if something in script is not clear. The first for loop is find unique no of ids and then grepping those uniq ids to find start and end time.
This exactly work like my previous code, how ever the pain area to get avg response time for each hour.
like in 24 hr format 00,01,02...23 for each hour avg responsetime would be assume if 10 hist then total response time( end time - start time) sum of response times for 10 hits/ 10