| 1 |
--- a/buffer.c |
| 2 |
+++ b/buffer.c |
| 3 |
@@ -976,17 +976,29 @@ |
| 4 |
ms_delta = (now.tv_sec - starttime.tv_sec) * 1000 |
| 5 |
+ (now.tv_usec - starttime.tv_usec) / 1000; |
| 6 |
if (ms_delta) { |
| 7 |
- /* Use increased accuracy for small amounts of data */ |
| 8 |
+ /* Use increased accuracy for small amounts of data, |
| 9 |
+ * decreased accuracy for *huge* throughputs > 4.1GB/s |
| 10 |
+ * to avoid division by 0. This will overflow if your |
| 11 |
+ * machine's throughput exceeds 4TB/s - you deserve to |
| 12 |
+ * lose if you're still using 32 bit longs on such a |
| 13 |
+ * beast ;-) |
| 14 |
+ * <[email protected]> |
| 15 |
+ */ |
| 16 |
if (outk < ULONG_MAX / 1000) { |
| 17 |
k_per_s = (outk * 1000) / ms_delta; |
| 18 |
- } else { |
| 19 |
+ } else if (ms_delta >= 1000) { |
| 20 |
k_per_s = outk / (ms_delta / 1000); |
| 21 |
+ } else { |
| 22 |
+ k_per_s = (outk / ms_delta) * 1000; |
| 23 |
} |
| 24 |
+ fprintf( stderr, " %10luK, %10luK/s\r", outk, k_per_s ); |
| 25 |
} else { |
| 26 |
- k_per_s = 0; |
| 27 |
+ if (outk) { |
| 28 |
+ fprintf( stderr, " %10luK, ?K/s\r", outk ); |
| 29 |
+ } else { |
| 30 |
+ fprintf( stderr, " 0K, 0K/s\r"); |
| 31 |
+ } |
| 32 |
} |
| 33 |
- |
| 34 |
- fprintf( stderr, " %10luK, %10luK/s\r", outk, k_per_s ); |
| 35 |
} |
| 36 |
|
| 37 |
#ifdef SYS5 |