diff options
author | Fengguang Wu <fengguang.wu@intel.com> | 2013-09-19 16:12:24 +0800 |
---|---|---|
committer | Fengguang Wu <fengguang.wu@intel.com> | 2013-09-29 12:15:34 +0800 |
commit | bd35a918574292567aa8fd81a778101c66fe741e (patch) | |
tree | 355f0d8ab95a67a45112521cc53e0d162997c606 | |
parent | 473aec7a65558dcaa3426883a371524db9befe0c (diff) | |
download | vm-scalability-bd35a918574292567aa8fd81a778101c66fe741e.tar.gz |
usemem: show throughput
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
-rw-r--r-- | usemem.c | 20 |
1 files changed, 17 insertions, 3 deletions
@@ -532,6 +532,11 @@ int do_unit(unsigned long bytes, struct drand48_data *rand_data) long do_units(unsigned long bytes) { struct drand48_data rand_data; + unsigned long remain_bytes = bytes; + unsigned long delta_us; + unsigned long throughput; + struct timeval start; + struct timeval stop; if (opt_detach) detach(); @@ -539,6 +544,8 @@ long do_units(unsigned long bytes) if (opt_randomise) os_random_seed(time(0) ^ getpid(), &rand_data); + gettimeofday(&start, NULL); + if (!unit) unit = bytes; /* @@ -546,13 +553,20 @@ long do_units(unsigned long bytes) * usemem -n 10000 0 --detach --sleep 10 */ do { - unsigned long size = min(bytes, unit); + unsigned long size = min(remain_bytes, unit); do_unit(size, &rand_data); - bytes -= size; + remain_bytes -= size; if (runtime_exceeded()) break; - } while (bytes); + } while (remain_bytes); + + gettimeofday(&stop, NULL); + delta_us = (stop.tv_sec - start.tv_sec) * 1000000 + + (stop.tv_usec - start.tv_usec); + throughput = (((bytes - remain_bytes) * 1000000ULL) >> 10) / delta_us; + printf("%lu bytes / %lu usecs = %lu KB/s\n", + bytes - remain_bytes, delta_us, throughput); if (opt_detach && up(sem_id)) perror("up"); |