Hi,
I've got a tiny benchmark that I'd like run on some high performance
machines (such as P90's running *BSD and/or Linux). Could you grab this
archive, unpack in a directory on a fast disk, and type
make mail
That will mail me the results. Thanks much, and note that some workstation
results are included.
Larry McVoy
#!/bin/sh
# This is a shell archive (produced by GNU shar 4.0).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1994-11-16 14:09 PST by <lm@slovax>.
# Source directory was `/u/lm/obench/fsbench'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 631 -r--r--r-- README
# 620 -r--r--r-- Makefile
# 2344 -r--r--r-- Results
# 1481 -r--r--r-- bench.h
# 7031 -r--r--r-- fsbench.c
# 4333 -r--r--r-- timing.c
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo 'WARNING: not restoring timestamps'
fi
rm -f 1231235999 $$.touch
#
# ============= README ==============
if test -f 'README' && test X"$1" != X"-c"; then
echo 'x - skipping README (File already exists)'
else
echo 'x - extracting README (text)'
sed 's/^X//' << 'SHAR_EOF' > 'README' &&
$Id: README,v 1.1 1994/11/16 22:08:53 lm Exp $
X
fsbench is a tiny, simple create & delete benchmark that I wrote to make
a point about FS performance. I'd like to get as many numbers as possible
with for good file systems. If you run this and get good numbers, please
send me the results.
X
Make sure you include
X
X (1) uname -a output
X (2) VFS type (UFS, NFS, TMPFS, whatever)
X (3) Processor & disk info (Mhz, arch, disk type)
X
Mail the results to l...@sgi.com and I'll post them.
X
To run the benchmark, just say
X
X $ cc fsbench.c timing.c
X $ a.out
X
It creates & deletes a bunch of files in $PWD. So go do it in a fast
file system.
SHAR_EOF
$shar_touch -am 1116140894 'README' &&
chmod 0444 'README' ||
echo 'restore of README failed'
shar_count="`wc -c < 'README'`"
test 631 -eq "$shar_count" ||
echo "README: original size 631, current size $shar_count"
fi
# ============= Makefile ==============
if test -f 'Makefile' && test X"$1" != X"-c"; then
echo 'x - skipping Makefile (File already exists)'
else
echo 'x - extracting Makefile (text)'
sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
# $Id: Makefile,v 1.1 1994/11/16 22:08:53 lm Exp $
X
all: fsbench
X fsbench
X
fsbench: fsbench.o timing.o
X $(CC) fsbench.o timing.o -o fsbench
X
mail: fsbench
X @echo 'Processor architecture (i.e., i486@66mhz)?'; \
X read proc; echo "Processor=$$proc" > MAIL
X uname -a >> MAIL
X if [ -f /etc/fstab ]; then cat /etc/fstab >> MAIL; fi
X if [ -f /etc/vfstab ]; then cat /etc/vfstab >> MAIL; fi
X if [ -x /etc/mount ]; then /etc/mount -p >> MAIL; fi
X if [ -x /sbin/mount ]; then /sbin/mount -p >> MAIL; fi
X pwd >> MAIL
X fsbench >> MAIL 2>&1
X mail l...@sgi.com < MAIL
X
clean:
X /bin/rm -f fsbench.o timing.o core a.out fsbench SHAR MAIL
SHAR_EOF
$shar_touch -am 1116140894 'Makefile' &&
chmod 0444 'Makefile' ||
echo 'restore of Makefile failed'
shar_count="`wc -c < 'Makefile'`"
test 620 -eq "$shar_count" ||
echo "Makefile: original size 620, current size $shar_count"
fi
# ============= Results ==============
if test -f 'Results' && test X"$1" != X"-c"; then
echo 'x - skipping Results (File already exists)'
else
echo 'x - extracting Results (text)'
sed 's/^X//' << 'SHAR_EOF' > 'Results' &&
$Id: Results,v 1.1 1994/11/16 22:08:53 lm Exp $
X
sunray 4/470 33Mhz SunOS 4.1.3
bucket 150mhz IP19 MP IRIX 5.3 alpha (debugging on, logical volumes on)
indy 100Mhz IP22 IRIX 5.3 alpha (debugging status unknown)
rios 62mhz rs6000 AIX 2.3 (fast & expensive machine)
alpha 250(?)mhz alpha OSF/1 V2.1 (I think this machine has NVRAM)
snake 100mhz HP snake HP-UX
X
X
X create delete
Host FS Size N /sec /sec
----------------------------------------------
sunray TMPFS 0k 500 1206 6021
sunray TMPFS 1k 500 735 3400
sunray TMPFS 4k 500 680 3061
sunray TMPFS 10k 500 455 3106
sunray NVRAM 0k 500 156 394
sunray NVRAM 1k 500 149 216
sunray NVRAM 4k 500 141 146
sunray NVRAM 10k 500 121 210
sunray UFS 0k 500 34 90
sunray UFS 1k 500 35 22
sunray UFS 4k 500 36 23
sunray UFS 10k 500 35 31
X
X create delete
Host FS Size N /sec /sec
----------------------------------------------
bucket XFS 0k 500 236 293
bucket XFS 1k 500 275 307
bucket XFS 4k 500 271 324
bucket XFS 10k 500 247 312
bucket EFS 0k 500 86 90
bucket EFS 1k 500 29 46
bucket EFS 4k 500 29 45
bucket EFS 10k 500 29 44
X
X create delete
Host FS Size N /sec /sec
----------------------------------------------
indy EFS 0k 500 86 87
indy EFS 1k 500 45 33
indy EFS 4k 500 38 33
indy EFS 10k 500 32 32
X
X create delete
Host FS Size N /sec /sec
----------------------------------------------
rios JFS 0k 500 79 79
rios JFS 1k 500 78 78
rios JFS 4k 500 78 79
rios JFS 10k 500 78 79
X
X create delete
Host FS Size N /sec /sec
----------------------------------------------
alpha UFS 0k 500 898 2944
alpha UFS 1k 500 180 195
alpha UFS 4k 500 118 199
alpha UFS 10k 500 74 171
X
X create delete
Host FS Size N /sec /sec
----------------------------------------------
snake HFS 0k 500 45 90
snake HFS 1k 500 30 45
snake HFS 4k 500 29 45
snake HFS 10k 500 22 45
SHAR_EOF
$shar_touch -am 1116140894 'Results' &&
chmod 0444 'Results' ||
echo 'restore of Results failed'
shar_count="`wc -c < 'Results'`"
test 2344 -eq "$shar_count" ||
echo "Results: original size 2344, current size $shar_count"
fi
# ============= bench.h ==============
if test -f 'bench.h' && test X"$1" != X"-c"; then
echo 'x - skipping bench.h (File already exists)'
else
echo 'x - extracting bench.h (text)'
sed 's/^X//' << 'SHAR_EOF' > 'bench.h' &&
/* $Id: bench.h,v 1.1 1994/11/16 22:08:53 lm Exp $ */
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
X
#ifdef NO_PORTMAPPER
#define TCP_XACT 3962
#define TCP_CONTROL 3963
#define TCP_DATA 3964
#define TCP_CONNECT 3965
#else
#define TCP_XACT (u_long)404039 /* XXX - unregistered */
#define TCP_CONTROL (u_long)404040 /* XXX - unregistered */
#define TCP_DATA (u_long)404041 /* XXX - unregistered */
#define TCP_CONNECT (u_long)404042 /* XXX - unregistered */
#define UDP_XACT (u_long)404032 /* XXX - unregistered */
#define VERS (u_long)1
#endif
X
#define SOCKBUF (48*1024) /* the magic size on suns */
X
#ifdef SYS5
#define bzero(b, len) memset(b, 0, len)
#define bcopy(s, d, l) memcpy(d, s, l)
#define rindex(s, c) strrchr(s, c)
#endif
X
#define ulong unsigned long
#define GO_AWAY signal(SIGALRM, exit); alarm(60 * 60);
X
void exit();
void start();
ulong stop();
void adjust();
void rusage();
void bandwidth();
void kb();
void mb();
void micro();
void milli();
void ptime();
void tvsub();
X
/*
X * Generated from msg.x which is included here:
X
X program XACT_PROG {
X version XACT_VERS {
X char
X RPC_XACT(char) = 1;
X } = 1;
X } = 3970;
X
X * Please do not edit this file.
X * It was generated using rpcgen.
X */
X
#include <rpc/types.h>
X
#define XACT_PROG ((u_long)3970)
#define XACT_VERS ((u_long)1)
#define RPC_XACT ((u_long)1)
#define RPC_EXIT ((u_long)2)
extern char *rpc_xact_1();
extern char *client_rpc_xact_1();
SHAR_EOF
$shar_touch -am 1116140894 'bench.h' &&
chmod 0444 'bench.h' ||
echo 'restore of bench.h failed'
shar_count="`wc -c < 'bench.h'`"
test 1481 -eq "$shar_count" ||
echo "bench.h: original size 1481, current size $shar_count"
fi
# ============= fsbench.c ==============
if test -f 'fsbench.c' && test X"$1" != X"-c"; then
echo 'x - skipping fsbench.c (File already exists)'
else
echo 'x - extracting fsbench.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'fsbench.c' &&
/*
X * Benchmark creates & deletes.
X */
/* $Id: fsbench.c,v 1.1 1994/11/16 22:08:53 lm Exp $ */
main()
{
X static int sizes[] = { 0, 1024, 4096, 10*1024 };
X extern char *names[];
X int i, j;
X double create_m, delete_m;
X char buf[100];
X
X for (i = 0; i < sizeof(sizes)/sizeof(int); ++i) {
X start();
X for (j = 0; j < 500; ++j) {
X mkfile(names[j], sizes[i]);
X }
X create_m = stop() / 1000000.;
X start();
X for (j = 0; j < 500; ++j) {
X unlink(names[j]);
X }
X delete_m = stop() / 1000000.;
X printf("%dk\t%d\t%.0f\t%.0f\n",
X sizes[i]>>10, 500,
X 500 / create_m, 500 / delete_m);
X }
X exit(0);
mkfile(s, sz)
X char *s;
{
X int fd = creat(s, 0666);
X char buf[10*1024]; /* XXX - track sizes */
X
X write(fd, buf, sz);
X close(fd);
char *names[] = {
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
"u", "v", "w", "x", "y", "z", "aa", "ab", "ac", "ad",
"ae", "af", "ag", "ah", "ai", "aj", "ak", "al", "am", "an",
"ao", "ap", "aq", "ar", "as", "at", "au", "av", "aw", "ax",
"ay", "az", "ba", "bb", "bc", "bd", "be", "bf", "bg", "bh",
"bi", "bj", "bk", "bl", "bm", "bn", "bo", "bp", "bq", "br",
"bs", "bt", "bu", "bv", "bw", "bx", "by", "bz", "ca", "cb",
"cc", "cd", "ce", "cf", "cg", "ch", "ci", "cj", "ck", "cl",
"cm", "cn", "co", "cp", "cq", "cr", "cs", "ct", "cu", "cv",
"cw", "cx", "cy", "cz", "da", "db", "dc", "dd", "de", "df",
"dg", "dh", "di", "dj", "dk", "dl", "dm", "dn", "do", "dp",
"dq", "dr", "ds", "dt", "du", "dv", "dw", "dx", "dy", "dz",
"ea", "eb", "ec", "ed", "ee", "ef", "eg", "eh", "ei", "ej",
"ek", "el", "em", "en", "eo", "ep", "eq", "er", "es", "et",
"eu", "ev", "ew", "ex", "ey", "ez", "fa", "fb", "fc", "fd",
"fe", "ff", "fg", "fh", "fi", "fj", "fk", "fl", "fm", "fn",
"fo", "fp", "fq", "fr", "fs", "ft", "fu", "fv", "fw", "fx",
"fy", "fz", "ga", "gb", "gc", "gd", "ge", "gf", "gg", "gh",
"gi", "gj", "gk", "gl", "gm", "gn", "go", "gp", "gq", "gr",
"gs", "gt", "gu", "gv", "gw", "gx", "gy", "gz", "ha", "hb",
"hc", "hd", "he", "hf", "hg", "hh", "hi", "hj", "hk", "hl",
"hm", "hn", "ho", "hp", "hq", "hr", "hs", "ht", "hu", "hv",
"hw", "hx", "hy", "hz", "ia", "ib", "ic", "id", "ie", "if",
"ig", "ih", "ii", "ij", "ik", "il", "im", "in", "io", "ip",
"iq", "ir", "is", "it", "iu", "iv", "iw", "ix", "iy", "iz",
"ja", "jb", "jc", "jd", "je", "jf", "jg", "jh", "ji", "jj",
"jk", "jl", "jm", "jn", "jo", "jp", "jq", "jr", "js", "jt",
"ju", "jv", "jw", "jx", "jy", "jz", "ka", "kb", "kc", "kd",
"ke", "kf", "kg", "kh", "ki", "kj", "kk", "kl", "km", "kn",
"ko", "kp", "kq", "kr", "ks", "kt", "ku", "kv", "kw", "kx",
"ky", "kz", "la", "lb", "lc", "ld", "le", "lf", "lg", "lh",
"li", "lj", "lk", "ll", "lm", "ln", "lo", "lp", "lq", "lr",
"ls", "lt", "lu", "lv", "lw", "lx", "ly", "lz", "ma", "mb",
"mc", "md", "me", "mf", "mg", "mh", "mi", "mj", "mk", "ml",
"mm", "mn", "mo", "mp", "mq", "mr", "ms", "mt", "mu", "mv",
"mw", "mx", "my", "mz", "na", "nb", "nc", "nd", "ne", "nf",
"ng", "nh", "ni", "nj", "nk", "nl", "nm", "nn", "no", "np",
"nq", "nr", "ns", "nt", "nu", "nv", "nw", "nx", "ny", "nz",
"oa", "ob", "oc", "od", "oe", "of", "og", "oh", "oi", "oj",
"ok", "ol", "om", "on", "oo", "op", "oq", "or", "os", "ot",
"ou", "ov", "ow", "ox", "oy", "oz", "pa", "pb", "pc", "pd",
"pe", "pf", "pg", "ph", "pi", "pj", "pk", "pl", "pm", "pn",
"po", "pp", "pq", "pr", "ps", "pt", "pu", "pv", "pw", "px",
"py", "pz", "qa", "qb", "qc", "qd", "qe", "qf", "qg", "qh",
"qi", "qj", "qk", "ql", "qm", "qn", "qo", "qp", "qq", "qr",
"qs", "qt", "qu", "qv", "qw", "qx", "qy", "qz", "ra", "rb",
"rc", "rd", "re", "rf", "rg", "rh", "ri", "rj", "rk", "rl",
"rm", "rn", "ro", "rp", "rq", "rr", "rs", "rt", "ru", "rv",
"rw", "rx", "ry", "rz", "sa", "sb", "sc", "sd", "se", "sf",
"sg", "sh", "si", "sj", "sk", "sl", "sm", "sn", "so", "sp",
"sq", "sr", "ss", "st", "su", "sv", "sw", "sx", "sy", "sz",
"ta", "tb", "tc", "td", "te", "tf", "tg", "th", "ti", "tj",
"tk", "tl", "tm", "tn", "to", "tp", "tq", "tr", "ts", "tt",
"tu", "tv", "tw", "tx", "ty", "tz", "ua", "ub", "uc", "ud",
"ue", "uf", "ug", "uh", "ui", "uj", "uk", "ul", "um", "un",
"uo", "up", "uq", "ur", "us", "ut", "uu", "uv", "uw", "ux",
"uy", "uz", "va", "vb", "vc", "vd", "ve", "vf", "vg", "vh",
"vi", "vj", "vk", "vl", "vm", "vn", "vo", "vp", "vq", "vr",
"vs", "vt", "vu", "vv", "vw", "vx", "vy", "vz", "wa", "wb",
"wc", "wd", "we", "wf", "wg", "wh", "wi", "wj", "wk", "wl",
"wm", "wn", "wo", "wp", "wq", "wr", "ws", "wt", "wu", "wv",
"ww", "wx", "wy", "wz", "xa", "xb", "xc", "xd", "xe", "xf",
"xg", "xh", "xi", "xj", "xk", "xl", "xm", "xn", "xo", "xp",
"xq", "xr", "xs", "xt", "xu", "xv", "xw", "xx", "xy", "xz",
"ya", "yb", "yc", "yd", "ye", "yf", "yg", "yh", "yi", "yj",
"yk", "yl", "ym", "yn", "yo", "yp", "yq", "yr", "ys", "yt",
"yu", "yv", "yw", "yx", "yy", "yz", "za", "zb", "zc", "zd",
"ze", "zf", "zg", "zh", "zi", "zj", "zk", "zl", "zm", "zn",
"zo", "zp", "zq", "zr", "zs", "zt", "zu", "zv", "zw", "zx",
"zy", "zz", "aaa", "aab", "aac", "aad", "aae", "aaf", "aag", "aah",
"aai", "aaj", "aak", "aal", "aam", "aan", "aao", "aap", "aaq", "aar",
"aas", "aat", "aau", "aav", "aaw", "aax", "aay", "aaz", "aba", "abb",
"abc", "abd", "abe", "abf", "abg", "abh", "abi", "abj", "abk", "abl",
"abm", "abn", "abo", "abp", "abq", "abr", "abs", "abt", "abu", "abv",
"abw", "abx", "aby", "abz", "aca", "acb", "acc", "acd", "ace", "acf",
"acg", "ach", "aci", "acj", "ack", "acl", "acm", "acn", "aco", "acp",
"acq", "acr", "acs", "act", "acu", "acv", "acw", "acx", "acy", "acz",
"ada", "adb", "adc", "add", "ade", "adf", "adg", "adh", "adi", "adj",
"adk", "adl", "adm", "adn", "ado", "adp", "adq", "adr", "ads", "adt",
"adu", "adv", "adw", "adx", "ady", "adz", "aea", "aeb", "aec", "aed",
"aee", "aef", "aeg", "aeh", "aei", "aej", "aek", "ael", "aem", "aen",
"aeo", "aep", "aeq", "aer", "aes", "aet", "aeu", "aev", "aew", "aex",
"aey", "aez", "afa", "afb", "afc", "afd", "afe", "aff", "afg", "afh",
"afi", "afj", "afk", "afl", "afm", "afn", "afo", "afp", "afq", "afr",
"afs", "aft", "afu", "afv", "afw", "afx", "afy", "afz", "aga", "agb",
"agc", "agd", "age", "agf", "agg", "agh", "agi", "agj", "agk", "agl",
"agm", "agn", "ago", "agp", "agq", "agr", "ags", "agt", "agu", "agv",
"agw", "agx", "agy", "agz", "aha", "ahb", "ahc", "ahd", "ahe", "ahf",
"ahg", "ahh", "ahi", "ahj", "ahk", "ahl", "ahm", "ahn", "aho", "ahp",
"ahq", "ahr", "ahs", "aht", "ahu", "ahv", "ahw", "ahx", "ahy", "ahz",
"aia", "aib", "aic", "aid", "aie", "aif", "aig", "aih", "aii", "aij",
"aik", "ail", "aim", "ain", "aio", "aip", "aiq", "air", "ais", "ait",
"aiu", "aiv", "aiw", "aix", "aiy", "aiz", "aja", "ajb", "ajc", "ajd",
"aje", "ajf", "ajg", "ajh", "aji", "ajj", "ajk", "ajl", "ajm", "ajn",
"ajo", "ajp", "ajq", "ajr", "ajs", "ajt", "aju", "ajv", "ajw", "ajx",
"ajy", "ajz", "aka", "akb", "akc", "akd", "ake", "akf", "akg", "akh",
"aki", "akj", "akk", "akl", "akm", "akn", "ako", "akp", "akq", "akr",
"aks", "akt", "aku", "akv", "akw", "akx", "aky", "akz", "ala", "alb",
"alc", "ald", "ale", "alf", "alg", "alh", "ali", "alj", "alk", "all",
$shar_touch -am 1116140894 'fsbench.c' &&
chmod 0444 'fsbench.c' ||
echo 'restore of fsbench.c failed'
shar_count="`wc -c < 'fsbench.c'`"
test 7031 -eq "$shar_count" ||
echo "fsbench.c: original size 7031, current size $shar_count"
fi
# ============= timing.c ==============
if test -f 'timing.c' && test X"$1" != X"-c"; then
echo 'x - skipping timing.c (File already exists)'
else
echo 'x - extracting timing.c (text)'
sed 's/^X//' << 'SHAR_EOF' > 'timing.c' &&
/*
X * $Id: timing.c,v 1.1 1994/11/16 22:08:53 lm Exp $
X *
X * Copyright (c) 1994 Larry McVoy.
X *
X * All output goes to stderr.
X */
#include "bench.h"
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
X
#ifdef RUSAGE
#include <sys/resource.h>
X
#define secs(tv) (tv.tv_sec + tv.tv_usec / 1000000.0)
#endif
X
#define nz(x) ((x) == 0 ? 1 : (x))
#define MB (1024*1024.0)
#define KB (1024.0)
X
#ifdef RUSAGE
X
#define mine(f) (ru_stop.f - ru_start.f)
X
static struct rusage ru_start, ru_stop;
X
void
rusage()
{
X struct rusage r;
X double sys, user, idle;
X double per;
X double timespent();
X
X sys = secs(ru_stop.ru_stime) - secs(ru_start.ru_stime);
X user = secs(ru_stop.ru_utime) - secs(ru_start.ru_utime);
X idle = timespent() - (sys + user);
X per = idle / timespent() * 100;
X fprintf(stderr, "real=%.2f sys=%.2f user=%.2f idle=%.2f stall=%.0f%% ",
X timespent(), sys, user, idle, per);
X fprintf(stderr, "rd=%d wr=%d min=%d maj=%d ctx=%d\n",
X mine(ru_inblock), mine(ru_oublock),
X mine(ru_minflt), mine(ru_majflt),
X mine(ru_nvcsw) + mine(ru_nivcsw));
#endif
X
static struct timeval start_tv, stop_tv;
X
/*
X * Start timing now.
X */
void
start()
{
X (void) gettimeofday(&start_tv, (struct timezone *) 0);
#ifdef RUSAGE
X getrusage(RUSAGE_SELF, &ru_start);
#endif
/*
X * Stop timing and return real time in microseconds.
X */
ulong
stop()
{
X struct timeval tdiff;
X
X (void) gettimeofday(&stop_tv, (struct timezone *) 0);
#ifdef RUSAGE
X getrusage(RUSAGE_SELF, &ru_stop);
#endif
X
X tvsub(&tdiff, &stop_tv, &start_tv);
X return (tdiff.tv_sec * 1000000 + tdiff.tv_usec);
ulong
now()
{
X struct timeval t;
X
X (void) gettimeofday(&t, (struct timezone *) 0);
X return (t.tv_usec / 100);
/*
X * Adjust time spent by usec amount.
X *
X * XXX - tv_usec may be too big after this.
X */
void
adjust(usec)
X int usec;
{
X int sec = usec / 1000000;
X
X usec -= sec * 1000000;
X stop_tv.tv_sec += sec;
X stop_tv.tv_usec += usec;
void
bandwidth(bytes, verbose)
X int bytes;
{
X struct timeval td;
X double s, bs;
X
X tvsub(&td, &stop_tv, &start_tv);
X s = td.tv_sec + td.tv_usec / 1000000.0;
X bs = bytes / nz(s);
X if (verbose) {
X (void) fprintf(stderr, "%.2f MB in %.2f secs, %.2f KB/sec\n",
X bytes / MB, s, bs / KB);
X } else {
X (void) fprintf(stderr, "%.2f %.2f\n",
X bytes / MB, bs / MB);
X }
void
kb(bytes)
X int bytes;
{
X struct timeval td;
X double s, bs;
X
X tvsub(&td, &stop_tv, &start_tv);
X s = td.tv_sec + td.tv_usec / 1000000.0;
X bs = bytes / nz(s);
X (void) fprintf(stderr, "%.0f KB/sec\n", bs / KB);
void
mb(bytes)
X int bytes;
{
X struct timeval td;
X double s, bs;
X
X tvsub(&td, &stop_tv, &start_tv);
X s = td.tv_sec + td.tv_usec / 1000000.0;
X bs = bytes / nz(s);
X (void) fprintf(stderr, "%.2f MB/sec\n", bs / MB);
void
latency(xfers, size)
X int xfers, size;
{
X struct timeval td;
X double s;
X
X tvsub(&td, &stop_tv, &start_tv);
X s = td.tv_sec + td.tv_usec / 1000000.0;
X fprintf(stderr,
X "%d xfers in %.2f secs, %.4f millisec/xfer, %.2f KB/sec\n",
X xfers, s, s * 1000 / xfers,
X (xfers * size) / (1024. * s));
void
context(xfers)
X int xfers;
{
X struct timeval td;
X double s;
X
X tvsub(&td, &stop_tv, &start_tv);
X s = td.tv_sec + td.tv_usec / 1000000.0;
X fprintf(stderr,
X "%d context switches in %.2f secs, %.0f microsec/switch\n",
X xfers, s, s * 1000000 / xfers);
void
micro(s, n)
X char *s;
X int n;
{
X struct timeval td;
X int micro;
X
X tvsub(&td, &stop_tv, &start_tv);
X micro = td.tv_sec * 1000000 + td.tv_usec;
X fprintf(stderr, "%s: %d microseconds\n", s, micro / n);
void
milli(s, n)
X char *s;
X int n;
{
X struct timeval td;
X int milli;
X
X tvsub(&td, &stop_tv, &start_tv);
X milli = td.tv_sec * 1000 + td.tv_usec / 1000;
X fprintf(stderr, "%s: %d milliseconds\n", s, milli / n);
void
ptime(n)
X int n;
{
X struct timeval td;
X double s;
X
X tvsub(&td, &stop_tv, &start_tv);
X s = td.tv_sec + td.tv_usec / 1000000.0;
X fprintf(stderr,
X "%d in %.2f secs, %.0f microseconds each\n", n, s, s * 1000000 / n);
void
tvsub(tdiff, t1, t0)
X struct timeval *tdiff, *t1, *t0;
{
X tdiff->tv_sec = t1->tv_sec - t0->tv_sec;
X tdiff->tv_usec = t1->tv_usec - t0->tv_usec;
X if (tdiff->tv_usec < 0)
X tdiff->tv_sec--, tdiff->tv_usec += 1000000;
double
timespent()
{
X struct timeval td;
X
X tvsub(&td, &stop_tv, &start_tv);
X return (td.tv_sec + td.tv_usec / 1000000);
$shar_touch -am 1116140894 'timing.c' &&
chmod 0444 'timing.c' ||
echo 'restore of timing.c failed'
shar_count="`wc -c < 'timing.c'`"
test 4333 -eq "$shar_count" ||
echo "timing.c: original size 4333, current size $shar_count"
fi
exit 0