aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFengguang Wu <fengguang.wu@intel.com>2013-10-04 11:05:35 +0800
committerFengguang Wu <fengguang.wu@intel.com>2013-10-04 11:05:35 +0800
commit9b74962fc51b9f699cf47fd01cf0d090e54cba33 (patch)
tree6d0e02aee5b7c1c847a9ea7a7ed4e8226dd75c33
parent141fdf406e4255b09664285e1e89e7b1a875d891 (diff)
downloadvm-scalability-9b74962fc51b9f699cf47fd01cf0d090e54cba33.tar.gz
usemem: fix disordered output due to race conditions
9163121194 bytes / 511443180 usecs = 17496 KB/s 9163121194 bytes / 535441190 usecs = 16712 KB/s 9163121194 bytes9167839786 bytes / 300795153 usecs = 29764 KB/s 9163121194 bytes / 301242067 usecs = 29704 KB/s 9167839786 bytes / 305479517 usecs = 29307 KB/s 9163121194 bytes / 303736171 usecs = 29460 KB/s 9167839786 bytes / 305661581 usecs = 29290 KB/s Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
-rw-r--r--usemem.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/usemem.c b/usemem.c
index f47dd77..aef10b1 100644
--- a/usemem.c
+++ b/usemem.c
@@ -555,13 +555,18 @@ long do_units(unsigned long bytes)
if (unit_bytes) {
struct timeval stop;
+ char buf[1024];
+ size_t len;
gettimeofday(&stop, NULL);
delta_us = (stop.tv_sec - start_time.tv_sec) * 1000000 +
(stop.tv_usec - start_time.tv_usec);
throughput = ((unit_bytes * 1000000ULL) >> 10) / delta_us;
- printf("%lu bytes / %lu usecs = %lu KB/s\n",
- unit_bytes, delta_us, throughput);
+ len = snprintf(buf, sizeof(buf),
+ "%lu bytes / %lu usecs = %lu KB/s\n",
+ unit_bytes, delta_us, throughput);
+ fflush(stdout);
+ write(1, buf, len);
}
if (opt_detach && up(sem_id))