aboutsummaryrefslogtreecommitdiffstats
path: root/timestats.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2005-08-22 07:12:20 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2005-08-22 07:12:20 +0000
commit5c63327c1abd4ab2d8ae80d9e86c5a61354cae37 (patch)
treedf3523ea31c067e87cc28e452eaa70b33a565774 /timestats.c
parent6d89f9b1575d633b44be15c3624db00be12e5651 (diff)
Add a "time_stat_init()" routine to initialize the fields of a
"timestat_t". Move "nstime_to_msec()" to "epan/nstime.c", as it has nothing to do with a "timestat_t". Use structure assignment when possible. Fix the "addtime()" macro and use it in "time_stat_update()". Use "timestat_t"s, and the routines to manipulate them, in the service response time table code. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@15509 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'timestats.c')
-rw-r--r--timestats.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/timestats.c b/timestats.c
index 18c1c6f58b..ed5cd5a86f 100644
--- a/timestats.c
+++ b/timestats.c
@@ -25,55 +25,45 @@
#include "timestats.h"
-/*
- * function: nstime_to_msec
- * converts nstime to gdouble, time base is milli seconds
- */
-
-gdouble nstime_to_msec(const nstime_t *time)
+/* Initialize a timestat_t struct */
+void
+time_stat_init(timestat_t *stats)
{
- return ((double)time->secs*1000 + (double)time->nsecs/1000000);
+ stats->num = 0;
+ stats->min.secs = 0;
+ stats->min.nsecs = 0;
+ stats->max.secs = 0;
+ stats->max.nsecs = 0;
+ stats->tot.secs = 0;
+ stats->tot.nsecs = 0;
}
-/* A Function to update a timestat_t struct with a new sample*/
-
+/* Update a timestat_t struct with a new sample */
void
time_stat_update(timestat_t *stats, const nstime_t *delta, packet_info *pinfo)
{
if(stats->num==0){
- stats->max.secs=delta->secs;
- stats->max.nsecs=delta->nsecs;
+ stats->max=*delta;
stats->max_num=pinfo->fd->num;
- }
-
- if(stats->num==0){
- stats->min.secs=delta->secs;
- stats->min.nsecs=delta->nsecs;
+ stats->min=*delta;
stats->min_num=pinfo->fd->num;
}
if( (delta->secs<stats->min.secs)
||( (delta->secs==stats->min.secs)
&&(delta->nsecs<stats->min.nsecs) ) ){
- stats->min.secs=delta->secs;
- stats->min.nsecs=delta->nsecs;
+ stats->min=*delta;
stats->min_num=pinfo->fd->num;
}
if( (delta->secs>stats->max.secs)
||( (delta->secs==stats->max.secs)
&&(delta->nsecs>stats->max.nsecs) ) ){
- stats->max.secs=delta->secs;
- stats->max.nsecs=delta->nsecs;
+ stats->max=*delta;
stats->max_num=pinfo->fd->num;
}
- stats->tot.secs += delta->secs;
- stats->tot.nsecs += delta->nsecs;
- if(stats->tot.nsecs>1000000000){
- stats->tot.nsecs-=1000000000;
- stats->tot.secs++;
- }
+ addtime(&stats->tot, delta);
stats->num++;
}