3 * \brief throughput testing program
7 * Copyright (c) 2007, 2008, 2009, 2010, 2011 ETH Zurich.
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
22 // Specific for barrelfish
23 #include <barrelfish/barrelfish.h>
25 #include <lwip/init.h>
26 #include <barrelfish/nameservice_client.h>
27 #include <barrelfish/waitset.h>
28 #include <contmng/netbench.h>
30 #define MOUNT_DIR "/nfs"
32 //uint8_t buf[1024 * 1024];
33 uint8_t buf[1024 * 128];
35 // reads the file over nfs
36 static int cat(char *path)
41 uint64_t filesize = 0;
43 err = vfs_open(path, &vh);
44 if (err_is_fail(err)) {
45 printf("%s: file not found\n", path);
49 uint64_t start = rdtsc();
50 lwip_benchmark_control(1, BMS_START_REQUEST, 0, 0);
52 err = vfs_read(vh, buf, sizeof(buf), &size);
53 if (err_is_fail(err)) {
54 // XXX: Close any files that might be open
55 DEBUG_ERR(err, "error reading file");
60 // fwrite(buf, 1, size, stdout);
64 uint64_t stop = rdtsc();
65 printf("Everythin done\n");
66 lwip_print_interesting_stats();
67 double speed = ((filesize/in_seconds(stop - start))/(1024 * 1024));
69 printf("Warning: NFS throughput too low!! [%f]\n", speed);
71 printf("## Data size = %f MB, Processing time [%"PU"], speed [%f] MB/s\n",
72 filesize/(double)(1024 * 1024), in_seconds(stop - start),
76 if (err_is_fail(err)) {
77 DEBUG_ERR(err, "in vfs_close");
83 int main(int argc, char**argv)
87 printf("Usage: %s mount-URL filepath\n", argv[0]);
88 printf("Example: %s nfs://10.110.4.41/shared /nfs/pravin/601.avi\n",
93 errval_t err = vfs_mkdir(MOUNT_DIR);
94 if(err_is_fail(err)) {
95 DEBUG_ERR(err, "vfs_mount");
98 err = vfs_mount(MOUNT_DIR, argv[1]);
99 if(err_is_fail(err)) {
100 DEBUG_ERR(err, "vfs_mount");
102 assert(err_is_ok(err));
103 printf("mount done\n");
105 printf("reading file [%s]\n", argv[2]);
107 printf("Benchmark done.\n");
109 struct waitset *ws = get_default_waitset();
111 err = event_dispatch(ws);
112 if (err_is_fail(err)) {
113 DEBUG_ERR(err, "in event_dispatch");