/****Copyright (c) 1995-2008 All rights reserved
 ****A. V. Gerbessiotis 
 ****Permission to use, copy, modify, and distribute this software,
 ****and to incorporate it, in whole or in part, into 
 ****other software,is hereby granted without fee, provided that
 ****  (1) the above copyright notice and this permission 
 ****      notice appear in all copies of the source code, and 
 ****      the above copyright notice appear in clearly visible 
 ****      form on all supporting documentation and distribution 
 ****      media, and
 ****     (2) any redistribution of the software, in original
 ****         or modified form, be without fee and subject to
 ****         these same conditions.
 ****   No guarantee, whatsoever, is offered that the code works as
 ****   advertised or is absent of any, even damaging,
 ****   side-effects. Use this code at your own personal risk.
 ****/

#include "avgtime.h"

static struct timeval _tstart, _tend;
static struct timezone _tstruct;

void   avg_tstart  (void);
void   avg_tend    (void);
double avg_treturn (void);

void avg_tstart(void) {
  gettimeofday(&_tstart, &_tstruct);
}

void avg_tend(void) {
  gettimeofday(&_tend,&_tstruct);
}

double avg_treturn(void) {
  double t1,t2;
  t1=(double)_tstart.tv_sec + (double)_tstart.tv_usec/(1000*1000);
  t2=(double)_tend.tv_sec + (double)_tend.tv_usec/(1000*1000);
  return(t2-t1);
}
