summaryrefslogtreecommitdiff
path: root/tools/readtest.c
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-01-20 18:29:35 +0100
committerRobin Gareus <robin@gareus.org>2015-01-20 18:29:35 +0100
commit4b470902c2f4405101888f1b4bce09925313f8ae (patch)
tree52686596ecaedf345137eff22405465ee5398753 /tools/readtest.c
parentdfba00766cf5a953f55fafa5618d9b97a5d5d4cc (diff)
few more read-test tweaks:
* add a file-limit option * print max elapsed read time
Diffstat (limited to 'tools/readtest.c')
-rw-r--r--tools/readtest.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/tools/readtest.c b/tools/readtest.c
index 42e95ce3cb..07d27faa46 100644
--- a/tools/readtest.c
+++ b/tools/readtest.c
@@ -1,4 +1,4 @@
-/* gcc -o readtest readtest.cc `pkg-config --cflags --libs glib-2.0` */
+/* gcc -o readtest readtest.c `pkg-config --cflags --libs glib-2.0` */
#include <stdlib.h>
#include <errno.h>
@@ -23,21 +23,23 @@ read_one (int fd, ssize_t sz)
void
usage ()
{
- fprintf (stderr, "readtest [ -b BLOCKSIZE ] [ -s ] [ -D ] filename-template\n");
+ fprintf (stderr, "readtest [ -b BLOCKSIZE ] [-l FILELIMIT] [ -D ] filename-template\n");
}
int
main (int argc, char* argv[])
{
int* files;
- char optstring[] = "b:D";
+ char optstring[] = "b:Dl:";
uint32_t block_size = 64 * 1024 * 4;
+ int max_files = -1;
#ifdef __APPLE__
bool direct = false;
#endif
const struct option longopts[] = {
{ "blocksize", 1, 0, 'b' },
{ "direct", 0, 0, 'D' },
+ { "limit", 1, 0, 'l' },
{ 0, 0, 0, 0 }
};
@@ -57,6 +59,9 @@ main (int argc, char* argv[])
case 'b':
block_size = atoi (optarg);
break;
+ case 'l':
+ max_files = atoi (optarg);
+ break;
case 'D':
#ifdef __APPLE__
direct = true;
@@ -85,6 +90,10 @@ main (int argc, char* argv[])
}
++n;
+
+ if (max_files > 0 && n >= max_files) {
+ break;
+ }
}
if (n == 0) {
@@ -126,7 +135,7 @@ main (int argc, char* argv[])
data = (char*) malloc (sizeof (char) * block_size);
uint64_t _read = 0;
- double min_throughput = -1;
+ double max_elapsed = 0;
double total_time = 0;
while (true) {
@@ -145,19 +154,21 @@ main (int argc, char* argv[])
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);
+ printf ("BW @ %lu %.3f seconds bandwidth %.4f MB/sec\n", (long unsigned int)_read, elapsed/1000000.0, bandwidth);
total_time += elapsed;
- if (min_throughput > bandwidth || min_throughput < 0) {
- min_throughput = bandwidth;
+
+ if (elapsed > max_elapsed) {
+ max_elapsed = elapsed;
}
}
out:
- if (min_throughput > 0 && total_time > 0) {
+ if (max_elapsed > 0 && total_time > 0) {
double bandwidth = ((nfiles * _read)/1048576.0) / (total_time/1000000.0);
- printf ("Min: %.4f MB/sec Avg: %.4f MB/sec\n", min_throughput, bandwidth);
+ double min_throughput = ((nfiles * block_size)/1048576.0) / (max_elapsed/1000000.0);
+ printf ("Min: %.4f MB/sec Avg: %.4f MB/sec || Max: %.3f sec \n", min_throughput, bandwidth, max_elapsed/1000000.0);
}
return 0;