#include #include #include void benchmallocfree32(B *b) { int i; for(i = 0; i < b->N; i++) { free(malloc(32)); } } void benchrand(B *b) { int i; for(i = 0; i < b->N; i++) { (void)rand(); } } void benchtruerand(B *b) { int i; for(i = 0; i < b->N; i++) { (void)truerand(); } } void benchinc(B *b) { int i; long inc; for(i = 0; i < b->N; i++) { inc++; } } void benchainc(B *b) { int i; long inc; for(i = 0; i < b->N; i++) { ainc(&inc); } } void benchfork(B *b) { int i; for(i = 0; i < b->N; i++){ if(!fork()) exits(nil); waitpid(); } } void benchforkexecl(B *b) { int i; for(i = 0; i < b->N; i++){ if(!fork()) execl("./8.true", nil); waitpid(); } } void main(void) { benchinit(); bench("mallocfree32", benchmallocfree32); bench("rand", benchrand); bench("truerand", benchtruerand); bench("inc", benchinc); bench("ainc", benchainc); bench("fork", benchfork); bench("forkexecl", benchforkexecl); exits(0); }