DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T t

⟦926608cb3⟧ TextFile

    Length: 1371 (0x55b)
    Types: TextFile
    Names: »timer.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« 
        └─⟦e5a54fb17⟧ 
            └─⟦this⟧ »pp-5.0/Lib/util/timer.c« 

TextFile

/* timer.c: utilities to provide timing information */

# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/util/RCS/timer.c,v 5.0 90/09/20 16:18:08 pp Exp Locker: pp $";
# endif

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Lib/util/RCS/timer.c,v 5.0 90/09/20 16:18:08 pp Exp Locker: pp $
 *
 * $Log:	timer.c,v $
 * Revision 5.0  90/09/20  16:18:08  pp
 * rcsforce : 5.0 public release
 * 
 */



#include "util.h"

#define NBBY 	8		/* no. bits / byte */

static void tvsub ();

void timer_start (tv)
struct timeval *tv;
{
	(void) gettimeofday (tv, (struct timezone *)0);
}

void timer_end (tv, cc, string)
struct timeval *tv;
int	cc;
char	*string;
{
	long                    ms;
	float                   bs;
	struct timeval stoptime, td;

	(void) gettimeofday (&stoptime, (struct timezone *)0);

	tvsub (&td, &stoptime, tv);
	ms = (td.tv_sec * 1000) + (td.tv_usec / 1000);
	bs = (((float) cc * NBBY * 1000) / (float) (ms ? ms : 1)) / NBBY;

	PP_NOTICE (("%s: %d bytes in %d.%02d seconds (%.2f Kbytes/s)",
		    string, cc, td.tv_sec, td.tv_usec / 10000, bs / 1024));
}

static void tvsub (tdiff, t1, t0)
register struct timeval *tdiff,
			*t1,
			*t0;
{
	tdiff -> tv_sec = t1 -> tv_sec - t0 -> tv_sec;
	tdiff -> tv_usec = t1 -> tv_usec - t0 -> tv_usec;
	if (tdiff -> tv_usec < 0)
		tdiff -> tv_sec--, tdiff -> tv_usec += 1000000;
}