Avarage Time

Hello, I calculate the total running time of the robot by, Timespan.FromTicks(sSpentTime.Sum(Function (x) CDate(x).TimeOfDay.Ticks)) . the time in the format 01:03:15:25:543216 the variable is type TimeSpan. to get the time in 27:15:25 format I use, System.Math.Floor ( TimeSpanVariable.TotalHours).tostring + TimeSpanVariable.ToString(“:mm:ss”) the variable is type String. How can I get an average processing time per transaction. For example: if the time is 27:15:25 and the number of transactions is 1000, the average time is 0:01:38?
both variables are String type. Time and number of requests

give a try at calculating the average on the base of ticks

so it works, through (spanvariable/ CInt(countTransaction)). ToString but again the format is 00:01:27:56456 for example I wish I could do it with the string variables


Can you try as the following?

yourString = "27.15:25"
arrTs = yourString.Split({":"c})
totalSec = 3600*Cint(arrTs(0))+60*CInt(arrTs(1))+CInt(arrTs(2))
ave = totalSec /1000



returns 00:01:38.1250000

arrTs is String array
totalSec is Int32
ave is Double

Hope this helps you.


Hey, whenever the string is generated fro a numerical base (eg. ticks) then also the same numercial value can be used for the avg calculation. As it is available, so we no need to reparse the former generated string within a numerical

when only 27:15:25 String is available then parse it as e.g. Yoichi showed