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 <netbench/netbench.h>
30 #define MOUNT_DIR "/nfs"
32 // reads the file over nfs
33 static int cat(char *path)
38 uint64_t filesize = 0;
40 err = vfs_open(path, &vh);
41 if (err_is_fail(err)) {
42 printf("%s: file not found\n", path);
46 struct vfs_fileinfo info;
47 err = vfs_stat(vh, &info);
49 printf("Could not stat file %s\n", path);
51 printf("Reading %d bytes from %s.\n", (int)info.size, path);
52 void *buf = malloc(10485760);
55 uint64_t start = rdtsc();
56 lwip_benchmark_control(1, BMS_START_REQUEST, 0, 0);
58 for (; filesize != info.size;) {
59 err = vfs_read(vh, buf, 10485760, &size);
60 if (err_is_fail(err)) {
61 // XXX: Close any files that might be open
62 DEBUG_ERR(err, "error reading file");
65 debug_printf("%s: %ld:%ld\n", __func__, filesize, info.size);
68 assert(info.size == filesize);
71 uint64_t stop = rdtsc();
72 printf("Everything done\n");
73 lwip_print_interesting_stats();
74 double speed = ((filesize/in_seconds(stop - start))/(1024 * 1024));
76 printf("Warning: NFS throughput too low!! [%f]\n", speed);
78 printf("## Data size = %f MB, Processing time [%"PU"], speed [%f] MB/s\n",
79 filesize/(double)(1024 * 1024), in_seconds(stop - start),
83 if (err_is_fail(err)) {
84 DEBUG_ERR(err, "in vfs_close");
90 int main(int argc, char**argv)
96 printf("Usage: %s mount-URL filepath\n", argv[0]);
97 printf("Example: %s nfs://10.110.4.41/shared /nfs/pravin/601.avi\n",
102 // don't have to do this, MOUNT_DIR is already there
103 // err = vfs_mkdir(MOUNT_DIR);
104 // if (err_is_fail(err)) {
105 // DEBUG_ERR(err, "vfs_mount");
108 err = vfs_mount(MOUNT_DIR, argv[1]);
109 if(err_is_fail(err)) {
110 DEBUG_ERR(err, "vfs_mount");
112 assert(err_is_ok(err));
113 printf("mount done\n");
115 printf("reading file 1. time [%s]\n", argv[2]);
117 printf("receive 1 done.\n");
120 printf("reading file 2. time [%s]\n", argv[2]);
122 printf("receive 2 done.\n"); */
123 printf("All done.\n");
125 struct waitset *ws = get_default_waitset();
127 err = event_dispatch(ws);
128 if (err_is_fail(err)) {
129 DEBUG_ERR(err, "in event_dispatch");