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 s

⟦df4028303⟧ TextFile

    Length: 1906 (0x772)
    Types: TextFile
    Names: »saxer8.c«

Derivation

└─⟦db229ac7e⟧ Bits:30007240 EUUGD20: SSBA 1.2 / AFW Benchmarks
    └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21E/saxer/saxer8.c« 

TextFile

#include <sys/types.h>
#include <sys/times.h>

#define DELAY	300

long	ticks, hz;
long	starttime, endtime;
static	int nbsec;
struct	tms ts;
extern	long time();

#ifdef VMUNIX /* BSD only */

#include "../install/signal.h"
#include <sys/time.h>
#include <sys/resource.h>
#include <setjmp.h>

struct	rlimit rlp;
int	cpu_before;
jmp_buf	jmpbuf;
int	sigxcpu();
long	t1;

int rtmsec()	/*  Real time in milliseconds.  (BSD) */
{
	static long epoch;

	if (epoch == 0 )
	{
		printf("checking time granularity ...\n");
		printf("waiting %d seconds\n", DELAY);
		signal(SIGXCPU, sigxcpu);
		getrlimit(RLIMIT_CPU, &rlp);
		cpu_before = rlp.rlim_cur;
		rlp.rlim_cur = DELAY;
		setrlimit(RLIMIT_CPU, &rlp);
		times(&ts);
		starttime=time( (long *) 0);
		t1 = ts.tms_utime;
		if (setjmp(jmpbuf) == 0) 
			for (;;) ;
	}
	times(&ts);
	epoch = ts.tms_utime;
	return (1000*epoch);
}

sigxcpu()
{
	times(&ts);
	endtime=time( (long *) 0);
	rlp.rlim_cur = cpu_before;
	setrlimit(RLIMIT_CPU, &rlp);
	ticks = ts.tms_utime - t1;
	hz = (ticks/DELAY + 5)/10 * 10;
	nbsec=(endtime-starttime);
	printf("measured waiting time : %d seconds\n", nbsec);
	printf("time granularity seems to be expressed in 1/%ld sec\n",hz);
	longjmp(jmpbuf, 1);
}

#else /* SYS5 */

extern long times();
extern unsigned sleep();

int rtmsec()	/*  Real time in milliseconds.  (System III)*/
{
	static long epoch;
	time_t starttime2, endtime2;

	if (epoch == 0 )
	{
		printf("checking time granularity ...\n");
		printf("waiting %d seconds\n", DELAY);
		starttime=time( (long *) 0);
		starttime2=times(&ts);
		sleep(DELAY);
		endtime=time( (long *) 0);
		endtime2=times(&ts);
		nbsec=(endtime-starttime);
		hz=((float)(endtime2-starttime2)/(float)(endtime-starttime))+.5;
		printf("measured waiting time : %d seconds\n", nbsec);
	printf("time granularity seems to be expressed in 1/%d sec\n",hz);
	}
	epoch = times(&ts);
	return (1000*epoch / hz );
}
#endif