Parametize all variables reading from command line; 
Change retry statistics accounting, one entry per time slot, update the corresponding time slot statistics by each query or update/insertion;
Change delay statistics accounting, separate normal query/update/insertion delay from retry delay, only average value for normal delay at a time slot.