* routines for time statistics
* Copyrigth 2003 Lars Roland
*
- * $Id: timestats.c,v 1.2 2003/09/03 10:10:17 sahlberg Exp $
+ * $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#include "timestats.h"
-/*
- * function: get_timedelta
- * delta = b - a
- */
-
-void get_timedelta(nstime_t *delta, nstime_t *b, nstime_t *a )
-{
- delta->secs = b->secs - a->secs;
- delta->nsecs= b->nsecs - a->nsecs;
- if(delta->nsecs<0){
- delta->nsecs+=1000000000;
- delta->secs--;
- }
-}
-
-/*
- * function: addtime
- * sum += a
- */
-
-void addtime(nstime_t *sum, nstime_t *a)
-{
- sum->secs += a->secs;
- sum->nsecs += a->nsecs;
- if(sum->nsecs>1000000000){
- sum->nsecs-=1000000000;
- sum->secs++;
- }
-}
-
/*
* function: nstime_to_msec
* converts nstime to gdouble, time base is milli seconds
*/
-gdouble nstime_to_msec(nstime_t *time)
+gdouble nstime_to_msec(const nstime_t *time)
{
return ((double)time->secs*1000 + (double)time->nsecs/1000000);
}
/* A Function to update a timestat_t struct with a new sample*/
void
-time_stat_update(timestat_t *stats, nstime_t *delta, packet_info *pinfo)
+time_stat_update(timestat_t *stats, const nstime_t *delta, packet_info *pinfo)
{
if(stats->num==0){
stats->max.secs=delta->secs;
* returns the average as a gdouble , time base is milli seconds
*/
-gdouble get_average(nstime_t *sum, guint32 num)
+gdouble get_average(const nstime_t *sum, guint32 num)
{
gdouble average;