LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   average of unix time stamps (https://www.linuxquestions.org/questions/linux-newbie-8/average-of-unix-time-stamps-870938/)

xeon123 03-25-2011 08:39 AM

average of unix time stamps
 
Hi,

I've these 2 UNIX timestamps values taken from the java method System.currentTimeMillis(). These 2 timestamps correspond to the start time and the end time of 2 process that ran. Here are the values:

Code:

starttime  ----------------    endtime
1301005328042  ----------- 1301005352079
1301005460357  ----------- 1301005484394

Now I would like to take an average of the duration that both tasks took. I was thing to do : (allendtime-allstarttimes)/2, but I think it's incorrect.

How can I take an average from UNIX timestamps?

Thanks,

rafatmb 03-25-2011 08:45 AM

Hi,

You can get a simple average doing that (allendtime-allstarttimes)/2.

But you can get very best average, with some more samples (you have only 2).

Take a look at this method (you can apply on your problem), but you must have more samples.

http://www.answers.com/topic/weighted-mean

[]'s

Rafa
Linux, Linux and Linux! Suporte Linux

xeon123 03-25-2011 08:49 AM

1- I've more numbers, of course. I just want to know from my timestamps if I can get an answer, for examples, that says to me that the average from these timestamps is 5 seconds.

I've the preference to do the average in bash, despite the values are taken from a java method.

2 - Thanks rafatmb of suggestion of the average mean, but I this it's not good for my case, because I can't take a weighted mean from time stamps that are totally different.


All times are GMT -5. The time now is 10:38 AM.