#!/bin/bash
##################################################
# Benchmark the processing time when wkhtmltopdf
# converts an html file to a pdf file
##################################################
if [[ $1 = "" || $2 = "" || $3 = "" ]]; then
echo "Usage: `basename $0` sourceFile.html destinationFile.pdf iteartionRunTime"
else
_min=9999
_max=0
_total=0
_iteration=$3
for (( _i=1; _i<=$_iteration; _i++ ))
do
_start_time=`date +%s`
echo "running $_i"
~MYUSER/bin/benchmarkWkhtmltopdf.sh $1 $2 > /dev/null 2>&1
_end_time=`date +%s`
_processing_time=$((_end_time-_start_time))
if [ "$_processing_time" -lt "$_min" ]; then
_min=$_processing_time
fi
if [ "$_processing_time" -gt "$_max" ]; then
_max=$_processing_time
fi
_total=$(($_total+$_processing_time))
done
_processing_time_average=$(echo - | awk "{print $_total/$_iteration}")
echo "Processing time avg: $_processing_time_average min:$_min max:$_max total:$_total"
fi