More benchmark stuff

上级 e1944711
...@@ -6,10 +6,12 @@ ...@@ -6,10 +6,12 @@
#define O_CREATE O_CREAT #define O_CREATE O_CREAT
#define xfork() fork() #define xfork() fork()
#define xexit() exit(EXIT_SUCCESS) #define xexit() exit(EXIT_SUCCESS)
typedef uint64_t u64;
#else #else
#include "types.h" #include "types.h"
#include "user.h" #include "user.h"
#include "fcntl.h" #include "fcntl.h"
#include "amd64.h"
#define xfork() fork(0) #define xfork() fork(0)
#define xexit() exit() #define xexit() exit()
#endif #endif
...@@ -73,6 +75,7 @@ main(int ac, char **av) ...@@ -73,6 +75,7 @@ main(int ac, char **av)
} }
close(fd); close(fd);
u64 t0 = rdtsc();
for (int i = 0; i < nthread; i++) { for (int i = 0; i < nthread; i++) {
int pid = xfork(); int pid = xfork();
if (pid == 0) if (pid == 0)
...@@ -81,5 +84,10 @@ main(int ac, char **av) ...@@ -81,5 +84,10 @@ main(int ac, char **av)
die("fork"); die("fork");
} }
for (int i = 0; i < nthread; i++)
wait();
u64 t1 = rdtsc();
printf("filebench: %lu\n", t1-t0);
return 0; return 0;
} }
...@@ -61,6 +61,10 @@ ...@@ -61,6 +61,10 @@
#define NCPU 2 #define NCPU 2
#define MTRACE 0 #define MTRACE 0
#define PERFSIZE (16<<20ull) #define PERFSIZE (16<<20ull)
#elif defined(HW_bench)
#define NCPU 48
#define MTRACE 0
#define PERFSIZE (16<<20ull)
#else #else
#error "Unknown HW" #error "Unknown HW"
#endif #endif
......
...@@ -43,13 +43,19 @@ setaffinity(int c) ...@@ -43,13 +43,19 @@ setaffinity(int c)
} }
static inline uint64_t static inline uint64_t
read_tsc(void) rdtsc(void)
{ {
uint64_t a, d; uint64_t a, d;
__asm __volatile("rdtsc" : "=a" (a), "=d" (d)); __asm __volatile("rdtsc" : "=a" (a), "=d" (d));
return ((uint64_t) a) | (((uint64_t) d) << 32); return ((uint64_t) a) | (((uint64_t) d) << 32);
} }
static inline uint64_t
read_tsc(void)
{
return rdtsc();
}
static inline void static inline void
rep_nop(void) rep_nop(void)
{ {
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论