diff options
author | Robin Gareus <robin@gareus.org> | 2015-01-20 00:57:22 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2015-01-20 00:57:22 +0100 |
commit | 899ee95ee0a953769ca537aa801f123357220c48 (patch) | |
tree | 033f9d80f67ef0accbc7d6a918d28592faaa5182 /tools | |
parent | 8ee58de3ec9fb9ba06ed89a1bb7c83e27336f3ac (diff) |
NOOP, re-indent
Diffstat (limited to 'tools')
-rw-r--r-- | tools/readtest.c | 99 |
1 files changed, 48 insertions, 51 deletions
diff --git a/tools/readtest.c b/tools/readtest.c index 301a5fa2bc..41c3a444af 100644 --- a/tools/readtest.c +++ b/tools/readtest.c @@ -17,7 +17,6 @@ char* data = 0; int read_one (int fd, ssize_t sz) { - return 0; } @@ -30,11 +29,11 @@ usage () int main (int argc, char* argv[]) { - int* files; + int* files; char optstring[] = "b:D"; uint32_t block_size = 64 * 1024 * 4; #ifdef __APPLE__ - bool direct = false; + bool direct = false; #endif const struct option longopts[] = { { "blocksize", 1, 0, 'b' }, @@ -45,9 +44,9 @@ main (int argc, char* argv[]) int option_index = 0; int c = 0; char const * name_template = 0; - int flags = O_RDONLY; - int n = 0; - int nfiles = 0; + int flags = O_RDONLY; + int n = 0; + int nfiles = 0; while (1) { if ((c = getopt_long (argc, argv, optstring, longopts, &option_index)) == -1) { @@ -55,17 +54,17 @@ main (int argc, char* argv[]) } switch (c) { - case 'b': - block_size = atoi (optarg); - break; - case 'D': + case 'b': + block_size = atoi (optarg); + break; + case 'D': #ifdef __APPLE__ - direct = true; + direct = true; #endif - break; - default: - usage (); - return 0; + break; + default: + usage (); + return 0; } } @@ -75,8 +74,8 @@ main (int argc, char* argv[]) usage (); return 1; } - - while (1) { + + while (1) { char path[PATH_MAX+1]; snprintf (path, sizeof (path), name_template, n+1); @@ -85,69 +84,67 @@ main (int argc, char* argv[]) break; } - ++n; - } + ++n; + } - if (n == 0) { - fprintf (stderr, "No matching files found for %s\n", name_template); - return 1; - } + if (n == 0) { + fprintf (stderr, "No matching files found for %s\n", name_template); + return 1; + } printf ("Discovered %d files using %s\n", n, name_template); - - nfiles = n; - files = (int *) malloc (sizeof (int) * nfiles); - for (n = 0; n < nfiles; ++n) { + nfiles = n; + files = (int *) malloc (sizeof (int) * nfiles); + + for (n = 0; n < nfiles; ++n) { char path[PATH_MAX+1]; - int fd; + int fd; snprintf (path, sizeof (path), name_template, n+1); - if ((fd = open (path, flags, 0644)) < 0) { + if ((fd = open (path, flags, 0644)) < 0) { fprintf (stderr, "Could not open file #%d @ %s (%s)\n", n, path, strerror (errno)); - return 1; - } + return 1; + } #ifdef __APPLE__ - if (direct) { - /* Apple man pages say only that it returns "a value other than -1 on success", - which probably means zero, but you just can't be too careful with - those guys. - */ - if (fcntl (fd, F_NOCACHE, 1) == -1) { - fprintf (stderr, "Cannot set F_NOCACHE on file #%d\n", n); - } - } + if (direct) { + /* Apple man pages say only that it returns "a value other than -1 on success", + which probably means zero, but you just can't be too careful with + those guys. + */ + if (fcntl (fd, F_NOCACHE, 1) == -1) { + fprintf (stderr, "Cannot set F_NOCACHE on file #%d\n", n); + } + } #endif - files[n] = fd; + files[n] = fd; } data = (char*) malloc (sizeof (char) * block_size); uint64_t _read = 0; - + while (true) { gint64 before; before = g_get_monotonic_time(); for (n = 0; n < nfiles; ++n) { - if (read (files[n], (char*) data, block_size) != block_size) { - fprintf (stderr, "read failed on file %d (%s)\n", n, strerror (errno)); - return -1; - } + if (read (files[n], (char*) data, block_size) != block_size) { + fprintf (stderr, "read failed on file %d (%s)\n", n, strerror (errno)); + return -1; + } } _read += block_size; gint64 elapsed = g_get_monotonic_time() - before; - double bandwidth = ((nfiles * block_size)/1048576.0) / (elapsed/1000000.0); - - printf ("BW @ %Lu %.3f seconds bandwidth %.4f MB/sec\n", _read, elapsed/1000000.0, bandwidth); + double bandwidth = ((nfiles * block_size)/1048576.0) / (elapsed/1000000.0); + + printf ("BW @ %Lu %.3f seconds bandwidth %.4f MB/sec\n", _read, elapsed/1000000.0, bandwidth); } return 0; } - - |