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

more aggressive dirbench

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