Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xv6-public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
问题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
银宸时代
OS Lab Group
奖励实验
xv6-public
提交
4c97b4dd
提交
4c97b4dd
4月 29, 2012
创建
作者:
Silas Boyd-Wickizer
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'old-types' into scale-amd64
上级
ca9a35c1
a05638cb
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
33 行增加
和
11 行删除
+33
-11
dirbench.cc
bin/dirbench.cc
+31
-9
filebench.cc
bin/filebench.cc
+1
-1
Makefrag.bench
user/Makefrag.bench
+1
-1
没有找到文件。
bin/dirbench.cc
浏览文件 @
4c97b4dd
#if defined(LINUX)
#include "user/util.h"
#include "types.h"
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <sys/stat.h>
#define O_CREATE O_CREAT
#define xfork() fork()
#define xexit() exit(EXIT_SUCCESS)
#define xmkdir(pathname) mkdir((pathname), S_IWUSR|S_IRUSR);
#define mtenable(x) do { } while(0)
#define mtdisable(x) do { } while(0)
#else
#include "types.h"
#include "types.h"
#include "stat.h"
#include "stat.h"
#include "user.h"
#include "user.h"
#include "mtrace.h"
#include "mtrace.h"
#include "amd64.h"
#include "amd64.h"
#include "fcntl.h"
#include "fcntl.h"
#define xfork() fork(0)
#define xexit() exit()
#define xmkdir(pathname) mkdir((pathname))
#endif
static
const
bool
pinit
=
true
;
static
const
bool
pinit
=
true
;
...
@@ -11,7 +29,7 @@ enum { nfile = 10 };
...
@@ -11,7 +29,7 @@ enum { nfile = 10 };
enum
{
nlookup
=
100
};
enum
{
nlookup
=
100
};
void
void
bench
(
u32
tid
,
int
nloop
)
bench
(
u32
tid
,
int
nloop
,
const
char
*
path
)
{
{
char
pn
[
MAXNAME
];
char
pn
[
MAXNAME
];
...
@@ -20,7 +38,7 @@ bench(u32 tid, int nloop)
...
@@ -20,7 +38,7 @@ bench(u32 tid, int nloop)
for
(
u32
x
=
0
;
x
<
nloop
;
x
++
)
{
for
(
u32
x
=
0
;
x
<
nloop
;
x
++
)
{
for
(
u32
i
=
0
;
i
<
nfile
;
i
++
)
{
for
(
u32
i
=
0
;
i
<
nfile
;
i
++
)
{
snprintf
(
pn
,
sizeof
(
pn
),
"
/dbx/f:%d:%d"
,
tid
,
i
);
snprintf
(
pn
,
sizeof
(
pn
),
"
%s/f:%d:%d"
,
path
,
tid
,
i
);
int
fd
=
open
(
pn
,
O_CREATE
|
O_RDWR
);
int
fd
=
open
(
pn
,
O_CREATE
|
O_RDWR
);
if
(
fd
<
0
)
if
(
fd
<
0
)
...
@@ -30,7 +48,7 @@ bench(u32 tid, int nloop)
...
@@ -30,7 +48,7 @@ bench(u32 tid, int nloop)
}
}
for
(
u32
i
=
0
;
i
<
nlookup
;
i
++
)
{
for
(
u32
i
=
0
;
i
<
nlookup
;
i
++
)
{
snprintf
(
pn
,
sizeof
(
pn
),
"
/dbx/f:%d:%d"
,
tid
,
(
i
%
nfile
));
snprintf
(
pn
,
sizeof
(
pn
),
"
%s/f:%d:%d"
,
path
,
tid
,
(
i
%
nfile
));
int
fd
=
open
(
pn
,
O_RDWR
);
int
fd
=
open
(
pn
,
O_RDWR
);
if
(
fd
<
0
)
if
(
fd
<
0
)
die
(
"open failed
\n
"
);
die
(
"open failed
\n
"
);
...
@@ -39,18 +57,19 @@ bench(u32 tid, int nloop)
...
@@ -39,18 +57,19 @@ bench(u32 tid, int nloop)
}
}
for
(
u32
i
=
0
;
i
<
nfile
;
i
++
)
{
for
(
u32
i
=
0
;
i
<
nfile
;
i
++
)
{
snprintf
(
pn
,
sizeof
(
pn
),
"
/dbx/f:%d:%d"
,
tid
,
i
);
snprintf
(
pn
,
sizeof
(
pn
),
"
%s/f:%d:%d"
,
path
,
tid
,
i
);
if
(
unlink
(
pn
)
<
0
)
if
(
unlink
(
pn
)
<
0
)
die
(
"unlink failed
\n
"
);
die
(
"unlink failed
\n
"
);
}
}
}
}
exit
();
x
exit
();
}
}
int
int
main
(
int
ac
,
char
**
av
)
main
(
int
ac
,
char
**
av
)
{
{
const
char
*
path
;
int
nthread
;
int
nthread
;
int
nloop
;
int
nloop
;
...
@@ -59,22 +78,25 @@ main(int ac, char** av)
...
@@ -59,22 +78,25 @@ main(int ac, char** av)
#else
#else
nloop
=
1000
;
nloop
=
1000
;
#endif
#endif
path
=
"/dbx"
;
if
(
ac
<
2
)
if
(
ac
<
2
)
die
(
"usage: %s nthreads [nloop]"
,
av
[
0
]);
die
(
"usage: %s nthreads [nloop]
[path]
"
,
av
[
0
]);
nthread
=
atoi
(
av
[
1
]);
nthread
=
atoi
(
av
[
1
]);
if
(
ac
>
2
)
if
(
ac
>
2
)
nloop
=
atoi
(
av
[
2
]);
nloop
=
atoi
(
av
[
2
]);
if
(
ac
>
3
)
path
=
av
[
3
];
mkdir
(
"/dbx"
);
xmkdir
(
path
);
mtenable
(
"xv6-dirbench"
);
mtenable
(
"xv6-dirbench"
);
u64
t0
=
rdtsc
();
u64
t0
=
rdtsc
();
for
(
u32
i
=
0
;
i
<
nthread
;
i
++
)
{
for
(
u32
i
=
0
;
i
<
nthread
;
i
++
)
{
int
pid
=
fork
(
0
);
int
pid
=
xfork
(
);
if
(
pid
==
0
)
if
(
pid
==
0
)
bench
(
i
,
nloop
);
bench
(
i
,
nloop
,
path
);
else
if
(
pid
<
0
)
else
if
(
pid
<
0
)
die
(
"fork"
);
die
(
"fork"
);
}
}
...
...
bin/filebench.cc
浏览文件 @
4c97b4dd
#if defined(LINUX)
#if defined(LINUX)
#include "user/util.h"
#include "user/util.h"
#include "types.h"
#include <fcntl.h>
#include <fcntl.h>
#include <unistd.h>
#include <unistd.h>
#include <assert.h>
#include <assert.h>
...
@@ -9,7 +10,6 @@
...
@@ -9,7 +10,6 @@
#define xcreat(name) open((name), O_CREATE|O_WRONLY, S_IRUSR|S_IWUSR)
#define xcreat(name) open((name), O_CREATE|O_WRONLY, S_IRUSR|S_IWUSR)
#define mtenable(x) do { } while(0)
#define mtenable(x) do { } while(0)
#define mtdisable(x) do { } while(0)
#define mtdisable(x) do { } while(0)
typedef
uint64_t
u64
;
#else
#else
#include "types.h"
#include "types.h"
#include "user.h"
#include "user.h"
...
...
user/Makefrag.bench
浏览文件 @
4c97b4dd
...
@@ -23,4 +23,4 @@ $(O)/%: $(O)/user/%.o
...
@@ -23,4 +23,4 @@ $(O)/%: $(O)/user/%.o
.PRECIOUS: $(O)/user/%.o
.PRECIOUS: $(O)/user/%.o
-include $(O)/user/*.d
-include $(O)/user/*.d
ALL := $(O)/filebench
ALL := $(O)/filebench
$(O)/dirbench
编写
预览
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论