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 f

⟦21aeb31f2⟧ TextFile

    Length: 3947 (0xf6b)
    Types: TextFile
    Names: »fstime.c«

Derivation

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

TextFile

/*
 * $Header: fstime.c,v 5.2 87/12/09 14:48:05 kenj Exp $
 */

#include <stdio.h>
#include "musbus.h"
#include <sys/types.h>
#ifdef SysV
#include <sys/times.h>
long	times();
#ifdef interdata
#define HZ tbuffer.tms_cfreq
#endif
#endif
#ifdef BSD4v1
#include <sys/timeb.h>
#endif
#ifdef BSD4v2
#include <sys/time.h>
#endif
#define NKBYTE 20
char buf[BUFSIZ];

main(argc, argv)
char **argv;
{
    int			n = NKBYTE;
    int			nblock;
    char		*fname;
    int			f;
    int			g;
    int			i;
    int			xfer, t;
    long		then;
    char		*mktemp();
#ifdef BSD4v1
    struct timeb	tbuf;
    int			msec;
#endif
#ifdef BSD4v2
    struct timeval	tval;
    struct timezone	tzone;
    long		usec;
#endif
#ifdef SysV
    struct tms		tbuffer;
#endif

    if (argc > 1)
	n = atoi(argv[1]);
    nblock = (n * 1024) / BUFSIZ;

    if (argc == 3 && chdir(argv[2]) != -1) {
    }
    fname = mktemp("fstXXXXXX");
    close(creat(fname, 0600));
    if ((f = open(fname, 2)) == -1) {
	fprintf(stderr, "fstime: open file #1 \"%s\" failed!\n", fname);
	exit(1);
    }
    unlink(fname);
    close(creat(fname, 0600));
    if ((g = open(fname, 2)) == -1) {
	fprintf(stderr, "fstime: open file #2 \"%s\" failed!\n", fname);
	exit(1);
    }
    unlink(fname);
    for (i = 0; i < sizeof(buf); i++)
	buf[i] = i & 0177;

#ifdef SysV
    then = times(&tbuffer);
#else
#ifdef BSD4v1
    ftime(&tbuf);
    then = tbuf.time;
    msec = tbuf.millitm;
#else
#ifdef BSD4v2
    gettimeofday(&tval, &tzone);
    then = tval.tv_sec;
    usec = tval.tv_usec;
#else
    What sort of Unix system if this?
#endif
#endif
#endif
    for (i = 0; i < nblock; i++) {
	if (write(f, buf, sizeof(buf)) != sizeof(buf)) {
	    perror("fstime: write");
	    exit(1);
	}
    }
#ifdef SysV
    t = 1000*(times(&tbuffer) - then)/HZ;
#endif
#ifdef BSD4v1
    ftime(&tbuf);
    t = (tbuf.time - then)*1000 + tbuf.millitm - msec;
#endif
#ifdef BSD4v2
    gettimeofday(&tval, &tzone);
    t = (tval.tv_sec - then)*1000 + (tval.tv_usec - usec)/1000;
#endif
    if (t > 0) {
	xfer = nblock * sizeof(buf) * 1000 / t;
    }
#if awk
    fprintf(stderr, "%.2f", t > 0 ? (float)xfer/1024 : 0);
#endif

    sync();
    sleep(5);
    sync();
    lseek(f, 0L, 0);
#ifdef SysV
    then = times(&tbuffer);
#endif
#ifdef BSD4v1
    times(&tbuf);
    then = tbuf.time;
    msec = tbuf.millitm;
#endif
#ifdef BSD4v2
    gettimeofday(&tval, &tzone);
    then = tval.tv_sec;
    usec = tval.tv_usec;
#endif
    for (i = 0; i < nblock; i++) {
	if (read(f, buf, sizeof(buf)) != sizeof(buf)) {
	    perror("fstime: read");
	    exit(1);
	}
    }
#ifdef SysV
    t = 1000*(times(&tbuffer) - then)/HZ;
#endif
#ifdef BSD4v1
    ftime(&tbuf);
    t = (tbuf.time - then)*1000 + tbuf.millitm - msec;
#endif
#ifdef BSD4v2
    gettimeofday(&tval, &tzone);
    t = (tval.tv_sec - then)*1000 + (tval.tv_usec - usec)/1000;
#endif
    if (t > 0) {
	xfer = nblock * sizeof(buf) * 1000 / t;
    }
#if awk
    fprintf(stderr, " %.2f", t > 0 ? (float)xfer/1024 : 0);
#endif

    sync();
    sleep(5);
    sync();
    lseek(f, 0L, 0);
#ifdef SysV
    then = times(&tbuffer);
#endif
#ifdef BSD4v1
    times(&tbuf);
    then = tbuf.time;
    msec = tbuf.millitm;
#endif
#ifdef BSD4v2
    gettimeofday(&tval, &tzone);
    then = tval.tv_sec;
    usec = tval.tv_usec;
#endif
    for (i = 0; i < nblock; i++) {
	if (read(f, buf, sizeof(buf)) != sizeof(buf)) {
	    perror("fstime: copy-read");
	    exit(1);
	}
	if (write(g, buf, sizeof(buf)) != sizeof(buf)) {
	    perror("fstime: copy-write");
	    exit(1);
	}
    }
#ifdef SysV
    t = 1000*(times(&tbuffer) - then)/HZ;
#endif
#ifdef BSD4v1
    ftime(&tbuf);
    t = (tbuf.time - then)*1000 + tbuf.millitm - msec;
#endif
#ifdef BSD4v2
    gettimeofday(&tval, &tzone);
    t = (tval.tv_sec - then)*1000 + (tval.tv_usec - usec)/1000;
#endif
    if (t > 0) {
	xfer = nblock * sizeof(buf) * 1000 / t;
    }
#if awk
    fprintf(stderr, " %.2f\n", t > 0 ? (float)xfer/1024 : 0);
#endif
    exit(0);
}