ref: 1046ee01c738fea18079cfbb2eb305b1e572b03b
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[10], *b; uchar d[1]; int f; ARGBEGIN{ }ARGEND b = &group[0]; 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, "proccreate"); while(b->n > 0){ benchin(b); proccreate(proc, (void*)b->n, 1024); benchout(b); } b++; benchinit(b, "memmove(4k)"); while(b->n > 0){ char *x, *y; x = malloc(4096); y = malloc(4096); benchin(b); memmove(x, y, 4096); benchout(b); free(x); free(y); } b++; benchinit(b, "memmove(64k)"); while(b->n > 0){ char *x, *y; x = malloc(65536); y = malloc(65536); benchin(b); memmove(x, y, 65536); benchout(b); free(x); free(y); } b++; benchinit(b, "memmove(256k)"); while(b->n > 0){ char *x, *y; x = malloc(256*1024); y = malloc(256*1024); benchin(b); memmove(x, y, 256*1024); benchout(b); free(x); free(y); } benchprint(group, nelem(group), 1); threadexitsall(nil); }