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

⟦86bcee5c9⟧ TextFile

    Length: 1676 (0x68c)
    Types: TextFile
    Names: »speed.c«

Derivation

└─⟦a05ed705a⟧ Bits:30007078 DKUUG GNU 2/12/89
    └─⟦ff23ba0e6⟧ »./ghostscript-1.3.tar.Z« 
        └─⟦a24a58cd3⟧ 
            └─⟦this⟧ »speed.c« 

TextFile

/* Test the speed of an 80x86 system */

#include <stdio.h>
#include <dos.h>
#include <stdlib.h>

typedef unsigned char byte;

/* Forward references */
long clock();
typedef void (*void_proc)();
void_proc make_loop(unsigned long instrs, int n);

main(int argc, char *argv[])
{	int i, j;
	long start;
	void_proc loop;
	/* Time 16K nops */
	loop = make_loop(0x40404040, 16000/4);	/* inc ax */
	start = clock();
	for ( i = 0; i < 1000; i++ ) loop();
	printf("16M nops = %ld ms\n", clock() - start);
	/* Time 4K 4-byte, 2-clock instructions */
	loop = make_loop(0x0000c0c7, 16000/4);	/* move 0,ax */
	start = clock();
	for ( i = 0; i < 1000; i++ ) loop();
	printf("4M 4-byte moves = %ld ms\n", clock() - start);
	/* Make 10 blocks of 16K nops and cycle between them, */
	/* to test cache miss time. */
	   {	void_proc loops[10];
		for ( i = 0; i < 10; i++ ) loops[i] = make_loop(0x40404040, 16000/4);
		for ( i = 0; i < 100; i++ )
		  for ( j = 0; j < 10; j++ ) loops[j]();
		printf("16M nops with cache misses = %ld ms\n", clock() - start);
	   }
}

/* Construct a routine consisting of N copies of a word. */
void_proc
make_loop(unsigned long word, int n)
{	byte *rtn = (byte *)malloc(n*4+1);
	unsigned long *ptr = (unsigned long *)rtn;
	int i;
	for ( i = 0; i < n; i++ ) *ptr++ = word;
	*(byte *)ptr = 0xcb;			/* far ret */
	return (void_proc)rtn;
}	

/* Read the current time (in milliseconds since midnight). */
long
clock()
{	struct time ostime;
	long itime;
	gettime(&ostime);
	itime = ostime.ti_hour;
	itime = itime * 60 + ostime.ti_min;
	itime = itime * 60 + ostime.ti_sec;
	itime = itime * 100 + ostime.ti_hund;
	itime = itime * 10;		/* milliseconds */
	return itime;
}