Displaying 3 results from an estimated 3 matches for "humansize".
Did you mean:
human_size
2019 Dec 04
6
[PATCH nbdkit v3 0/5] filters: stats: More useful, more friendly
This is the third attempt to make the stats filter better. This time I kept the
changes minimal to make it eaier to make progress.
I tried the idea of showing global stats in separate "total" section, but it
became messy and hard to implemnt, so I tried the simpler solution of showing
both operation rate and total rate in the operation line.
Nir Soffer (5):
filters: stats: Add
2019 Dec 03
2
[PATCH nbdkit] filters: stats: Show size and rate in human size
...0 @@ static stat extents_st = { "extents" };
static stat cache_st = { "cache" };
static stat flush_st = { "flush" };
-static inline double
-calc_bps (uint64_t bytes, int64_t usecs)
+#define KiB 1024
+#define MiB 1048576
+#define GiB 1073741824
+
+static char *
+humansize(uint64_t bytes)
{
- return 8.0 * bytes / usecs * 1000000.;
+ char buf[32];
+
+ if (bytes < KiB)
+ snprintf (buf, sizeof(buf), "%" PRIu64 " bytes", bytes);
+ else if (bytes < MiB)
+ snprintf (buf, sizeof(buf), "%.2f KiB", bytes / (double)K...
2019 Dec 04
0
[PATCH nbdkit v3 5/5] filters: stats: Show total stats
...at *st, int64_t usecs)
}
}
+static void
+print_totals (uint64_t usecs)
+{
+ uint64_t ops = pread_st.ops + pwrite_st.ops + trim_st.ops + zero_st.ops +
+ extents_st.ops + flush_st.ops;
+ uint64_t bytes = pread_st.bytes + pwrite_st.bytes + trim_st.bytes +
+ zero_st.bytes;
+ char *size = humansize (bytes);
+ char *rate = humanrate (bytes, usecs);
+
+ fprintf (fp, "total: %" PRIu64 " ops, %.6f s, %s, %s/s\n",
+ ops, usecs / 1000000.0, maybe (size), maybe (rate));
+
+ free (size);
+ free (rate);
+}
+
static inline void
print_stats (int64_t usecs)
{
- fprin...