]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
rxperf: print achieved transfer rate
authorDan van der Ster <daniel.vanderster@cern.ch>
Fri, 14 Dec 2012 10:08:44 +0000 (11:08 +0100)
committerStephan Wiesand <stephan.wiesand@desy.de>
Sat, 30 Mar 2013 14:59:10 +0000 (07:59 -0700)
Prints the client transfer rate in appropriate units (kbit/s, Mbit/s, or Gbit/s).

Reviewed-on: http://gerrit.openafs.org/8758
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
(cherry picked from commit 07d83cd473146a0db9c2ed521b6fa6ba607b0d40)

Change-Id: Ia17b315e79313407e5479cd3710ac454d56ee7dd
Reviewed-on: http://gerrit.openafs.org/9682
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Dan van der Ster <daniel.vanderster@cern.ch>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/rx/test/rxperf.c

index ffbf0c167a3b970e402186cab09777326d7abd72..4983905f567676961665655ba70e57ba46f45d88 100644 (file)
@@ -217,16 +217,25 @@ start_timer(void)
  */
 
 static void
-end_and_print_timer(char *str)
+end_and_print_timer(char *str, long long bytes)
 {
     long long start_l, stop_l;
+    double kbps;
 
     timer_check--;
     assert(timer_check == 0);
     gettimeofday(&timer_stop, NULL);
     start_l = timer_start.tv_sec * 1000000 + timer_start.tv_usec;
     stop_l = timer_stop.tv_sec * 1000000 + timer_stop.tv_usec;
-    printf("%s:\t%8llu msec\n", str, (stop_l - start_l) / 1000);
+    printf("%s:\t%8llu msec", str, (stop_l - start_l) / 1000);
+
+    kbps = bytes * 8000.0 / (stop_l - start_l);
+    if (kbps > 1000000.0)
+        printf("\t[%.4g Gbit/s]\n", kbps/1000000.0);
+    else if (kbps > 1000.0)
+        printf("\t[%.4g Mbit/s]\n", kbps/1000.0);
+    else
+        printf("\t[%.4g kbit/s]\n", kbps);
 }
 
 /*
@@ -892,7 +901,17 @@ do_client(const char *server, short port, char *filename, afs_int32 command,
         pthread_join(thread[i], &status);
 #endif
 
-    end_and_print_timer(stamp);
+    switch (command) {
+    case RX_PERF_RPC:
+        end_and_print_timer(stamp, (long long)threads*times*(sendbytes+readbytes));
+        break;
+    case RX_PERF_RECV:
+    case RX_PERF_SEND:
+    case RX_PERF_FILE:
+        end_and_print_timer(stamp, (long long)threads*times*bytes);
+        break;
+    }
+
     DBFPRINT(("done for good\n"));
 
     if (dumpstats) {