提交 cb1f03f7 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

more aggressive dirbench

上级 2b3ba5b1
...@@ -7,8 +7,9 @@ ...@@ -7,8 +7,9 @@
#include "fcntl.h" #include "fcntl.h"
enum { nthread = 2 }; enum { nthread = 2 };
enum { nloop = 100 };
enum { nfile = 10 }; enum { nfile = 10 };
enum { nlookup = 1000 }; enum { nlookup = 100 };
char dirs[nthread][MAXNAME]; char dirs[nthread][MAXNAME];
void void
...@@ -16,12 +17,13 @@ bench(uint tid) ...@@ -16,12 +17,13 @@ bench(uint tid)
{ {
char pn[MAXNAME]; char pn[MAXNAME];
for (uint x = 0; x < nloop; x++) {
for (uint i = 0; i < nfile; i++) { for (uint i = 0; i < nfile; i++) {
snprintf(pn, sizeof(pn), "%s/f:%d:%d", dirs[tid], tid, i); snprintf(pn, sizeof(pn), "%s/f:%d:%d", dirs[tid], tid, i);
int fd = open(pn, O_CREATE | O_RDWR); int fd = open(pn, O_CREATE | O_RDWR);
if (fd < 0) if (fd < 0)
printf(1, "create failed"); printf(1, "create failed\n");
close(fd); close(fd);
} }
...@@ -30,11 +32,18 @@ bench(uint tid) ...@@ -30,11 +32,18 @@ bench(uint tid)
snprintf(pn, sizeof(pn), "%s/f:%d:%d", dirs[tid], tid, (i % nfile)); snprintf(pn, sizeof(pn), "%s/f:%d:%d", dirs[tid], tid, (i % nfile));
int fd = open(pn, O_RDWR); int fd = open(pn, O_RDWR);
if (fd < 0) if (fd < 0)
printf(1, "open failed"); printf(1, "open failed\n");
close(fd); close(fd);
} }
for (uint i = 0; i < nfile; i++) {
snprintf(pn, sizeof(pn), "%s/f:%d:%d", dirs[tid], tid, i);
if (unlink(pn) < 0)
printf(1, "unlink failed\n");
}
}
exit(); exit();
} }
...@@ -42,9 +51,10 @@ int ...@@ -42,9 +51,10 @@ int
main(void) main(void)
{ {
for (uint i = 0; i < nthread; i++) { for (uint i = 0; i < nthread; i++) {
snprintf(dirs[i], sizeof(dirs[i]), "/db%d", i); //snprintf(dirs[i], sizeof(dirs[i]), "/db%d", i);
snprintf(dirs[i], sizeof(dirs[i]), "/dbx");
if (mkdir(dirs[i]) < 0) if (mkdir(dirs[i]) < 0)
printf(1, "mkdir failed"); printf(1, "mkdir failed\n");
} }
mtrace_enable_set(1, "xv6-dirbench"); mtrace_enable_set(1, "xv6-dirbench");
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论