ref: bbdcad5c85ca1a0daa21bf1f8f70ea9394cb7a02
dir: /main.c/
#include <u.h> #include <libc.h> #include <thread.h> #include "b.h" static void proc(void *) { threadexits(nil); } void threadmain(int argc, char **argv) { B *group, *b; uchar d[1]; char t[64]; int f; ARGBEGIN{ }ARGEND snprint(t, sizeof(t), "/proc/%d/ctl", getpid()); if((f = open(t, OWRITE)) < 0) fprint(2, "%r\n"); else{ if(write(f, "wired 0\n", 8) != 8) fprint(2, "failed to wire\n"); close(f); } b = group = malloc(32 * sizeof(*b)); f = open("/dev/null", OREAD); benchinit(b, "read/1"); while(b->n > 0){ benchin(b); read(f, d, 1); benchout(b); } b++; benchinit(b, "read/0"); while(b->n > 0){ benchin(b); read(f, d, 0); benchout(b); } close(f); b++; benchinit(b, "sin(n)"); while(b->n > 0){ benchin(b); sin(b->n); benchout(b); } b++; benchinit(b, "cos(n)"); while(b->n > 0){ benchin(b); cos(b->n); benchout(b); } b++; benchinit(b, "tan(n)"); while(b->n > 0){ benchin(b); tan(b->n); benchout(b); } b++; benchinit(b, "sleep(0)"); while(b->n > 0){ benchin(b); sleep(0); benchout(b); } b++; benchinit(b, "sleep(5)"); while(b->n > 0){ benchin(b); sleep(5); benchout(b); } b++; benchinit(b, "sleep(10)"); while(b->n > 0){ benchin(b); sleep(10); benchout(b); } b++; benchinit(b, "proccreate"); while(b->n > 0){ benchin(b); proccreate(proc, (void*)b->n, 1024); benchout(b); } b++; benchprint(group, b-group, 1); threadexitsall(nil); }