summaryrefslogtreecommitdiff
path: root/ioshark
diff options
context:
space:
mode:
authorMohan Srinivasan <srmohan@google.com>2017-02-22 16:19:25 -0800
committerMohan Srinivasan <srmohan@google.com>2017-02-22 16:20:51 -0800
commit2aa6e6fbda3ac6781efd022f01f8006cedda878d (patch)
tree57a39f6007da83e84f3bd90c25e1cfba953864ae /ioshark
parent08357dfe620c32a72de0c598a078dde01991cdb8 (diff)
downloadextras-2aa6e6fbda3ac6781efd022f01f8006cedda878d.tar.gz
Add a summary (-s) option for easier parseability.
Add a summary (-s) option that dumps out the metrics from the run on one single line for easier parseability. Requested by Shankhoneer for easier integration of ioshark into tradefed. Test: Test the new -s option (and combination with other options) to make sure everything continues to work. Change-Id: Ic27306a89bb501ce5b31f8df2ef9c583f56e9e4a Signed-off-by: Mohan Srinivasan <srmohan@google.com>
Diffstat (limited to 'ioshark')
-rw-r--r--ioshark/ioshark_bench.c84
-rw-r--r--ioshark/ioshark_bench_subr.c34
2 files changed, 83 insertions, 35 deletions
diff --git a/ioshark/ioshark_bench.c b/ioshark/ioshark_bench.c
index ce7ab01e..670ec757 100644
--- a/ioshark/ioshark_bench.c
+++ b/ioshark/ioshark_bench.c
@@ -55,6 +55,7 @@ pthread_t tid[MAX_THREADS];
*/
int do_delay = 0;
int verbose = 0;
+int summary_mode = 0;
#if 0
static long gettid()
@@ -581,7 +582,7 @@ main(int argc, char **argv)
struct thread_state_s *state;
progname = argv[0];
- while ((c = getopt(argc, argv, "dn:t:v")) != EOF) {
+ while ((c = getopt(argc, argv, "dn:st:v")) != EOF) {
switch (c) {
case 'd':
do_delay = 1;
@@ -589,6 +590,10 @@ main(int argc, char **argv)
case 'n':
num_iterations = atoi(optarg);
break;
+ case 's':
+ /* Non-verbose summary mode for nightly runs */
+ summary_mode = 1;
+ break;
case 't':
num_threads = atoi(optarg);
break;
@@ -600,6 +605,9 @@ main(int argc, char **argv)
}
}
+ if ((verbose + summary_mode) == 2)
+ usage();
+
if (num_threads > MAX_THREADS)
usage();
@@ -657,7 +665,8 @@ main(int argc, char **argv)
struct timeval time_for_pass;
/* Create files once */
- printf("Doing Pre-creation of Files\n");
+ if (!summary_mode)
+ printf("Doing Pre-creation of Files\n");
if (num_threads == 0 || num_threads > num_files)
num_threads = num_files;
(void)system("echo 3 > /proc/sys/vm/drop_caches");
@@ -679,11 +688,13 @@ main(int argc, char **argv)
/* Do the IOs N times */
for (i = 0 ; i < num_iterations ; i++) {
(void)system("echo 3 > /proc/sys/vm/drop_caches");
- if (num_iterations > 1)
- printf("Starting Test. Iteration %d...\n",
- i);
- else
- printf("Starting Test...\n");
+ if (!summary_mode) {
+ if (num_iterations > 1)
+ printf("Starting Test. Iteration %d...\n",
+ i);
+ else
+ printf("Starting Test...\n");
+ }
init_work(start_file, num_files);
(void)gettimeofday(&time_for_pass,
(struct timezone *)NULL);
@@ -715,24 +726,43 @@ main(int argc, char **argv)
files_db_free_memory(state->db_handle);
}
}
- printf("Total Creation time = %ju.%ju (msecs.usecs)\n",
- get_msecs(&aggregate_file_create_time),
- get_usecs(&aggregate_file_create_time));
- printf("Total Remove time = %ju.%ju (msecs.usecs)\n",
- get_msecs(&aggregate_file_remove_time),
- get_usecs(&aggregate_file_remove_time));
- if (do_delay)
- printf("Total delay time = %ju.%ju (msecs.usecs)\n",
- get_msecs(&aggregate_delay_time),
- get_usecs(&aggregate_delay_time));
- printf("Total Test (IO) time = %ju.%ju (msecs.usecs)\n",
- get_msecs(&aggregate_IO_time),
- get_usecs(&aggregate_IO_time));
- if (verbose)
- print_bytes("Upfront File Creation bytes",
- &aggr_create_rw_bytes);
- print_bytes("Total Test (IO) bytes", &aggr_io_rw_bytes);
- if (verbose)
- print_op_stats(aggr_op_counts);
- report_cpu_disk_util();
+ if (!summary_mode) {
+ printf("Total Creation time = %ju.%ju (msecs.usecs)\n",
+ get_msecs(&aggregate_file_create_time),
+ get_usecs(&aggregate_file_create_time));
+ printf("Total Remove time = %ju.%ju (msecs.usecs)\n",
+ get_msecs(&aggregate_file_remove_time),
+ get_usecs(&aggregate_file_remove_time));
+ if (do_delay)
+ printf("Total delay time = %ju.%ju (msecs.usecs)\n",
+ get_msecs(&aggregate_delay_time),
+ get_usecs(&aggregate_delay_time));
+ printf("Total Test (IO) time = %ju.%ju (msecs.usecs)\n",
+ get_msecs(&aggregate_IO_time),
+ get_usecs(&aggregate_IO_time));
+ if (verbose)
+ print_bytes("Upfront File Creation bytes",
+ &aggr_create_rw_bytes);
+ print_bytes("Total Test (IO) bytes", &aggr_io_rw_bytes);
+ if (verbose)
+ print_op_stats(aggr_op_counts);
+ report_cpu_disk_util();
+ } else {
+ printf("%ju.%ju ",
+ get_msecs(&aggregate_file_create_time),
+ get_usecs(&aggregate_file_create_time));
+ printf("%ju.%ju ",
+ get_msecs(&aggregate_file_remove_time),
+ get_usecs(&aggregate_file_remove_time));
+ if (do_delay)
+ printf("%ju.%ju ",
+ get_msecs(&aggregate_delay_time),
+ get_usecs(&aggregate_delay_time));
+ printf("%ju.%ju ",
+ get_msecs(&aggregate_IO_time),
+ get_usecs(&aggregate_IO_time));
+ print_bytes(NULL, &aggr_io_rw_bytes);
+ report_cpu_disk_util();
+ printf("\n");
+ }
}
diff --git a/ioshark/ioshark_bench_subr.c b/ioshark/ioshark_bench_subr.c
index 06a6d99d..1b0ecf98 100644
--- a/ioshark/ioshark_bench_subr.c
+++ b/ioshark/ioshark_bench_subr.c
@@ -30,6 +30,7 @@
#include "ioshark_bench.h"
extern char *progname;
+extern int verbose, summary_mode;
void *
files_db_create_handle(void)
@@ -307,10 +308,15 @@ print_op_stats(u_int64_t *op_counts)
void
print_bytes(char *desc, struct rw_bytes_s *rw_bytes)
{
- printf("%s: Reads = %dMB, Writes = %dMB\n",
- desc,
- (int)(rw_bytes->bytes_read / (1024 * 1024)),
- (int)(rw_bytes->bytes_written / (1024 * 1024)));
+ if (!summary_mode)
+ printf("%s: Reads = %dMB, Writes = %dMB\n",
+ desc,
+ (int)(rw_bytes->bytes_read / (1024 * 1024)),
+ (int)(rw_bytes->bytes_written / (1024 * 1024)));
+ else
+ printf("%d %d ",
+ (int)(rw_bytes->bytes_read / (1024 * 1024)),
+ (int)(rw_bytes->bytes_written / (1024 * 1024)));
}
struct cpu_disk_util_stats {
@@ -504,18 +510,27 @@ report_cpu_disk_util(void)
tot1 += before.iowait_cpu_ticks + before.idle_cpu_ticks;
delta2 = tot2 - tot1;
cpu_util = delta1 * 100.0 / delta2;
- printf("CPU util = %.2f%%\n", cpu_util);
+ if (!summary_mode)
+ printf("CPU util = %.2f%%\n", cpu_util);
+ else
+ printf("%.2f ", cpu_util);
/* Next compute system (incl irq/softirq) and user cpu util */
delta1 = (after.user_cpu_ticks + after.nice_cpu_ticks) -
(before.user_cpu_ticks + before.nice_cpu_ticks);
cpu_util = delta1 * 100.0 / delta2;
- printf("User CPU util = %.2f%%\n", cpu_util);
+ if (!summary_mode)
+ printf("User CPU util = %.2f%%\n", cpu_util);
+ else
+ printf("%.2f ", cpu_util);
delta1 = (after.system_cpu_ticks + after.hardirq_cpu_ticks +
after.softirq_cpu_ticks) -
(before.system_cpu_ticks + before.hardirq_cpu_ticks +
before.softirq_cpu_ticks);
cpu_util = delta1 * 100.0 / delta2;
- printf("System CPU util = %.2f%%\n", cpu_util);
+ if (!summary_mode)
+ printf("System CPU util = %.2f%%\n", cpu_util);
+ else
+ printf("%.2f ", cpu_util);
/* Disk Util */
disk_util = (after.tot_ticks - before.tot_ticks) * 100.0 /
(after.uptime - before.uptime);
@@ -527,5 +542,8 @@ report_cpu_disk_util(void)
(after.wr_ios - before.wr_ios),
(after.wr_sec - before.wr_sec) / 2048);
}
- printf("Disk util = %.2f%%\n", disk_util);
+ if (!summary_mode)
+ printf("Disk util = %.2f%%\n", disk_util);
+ else
+ printf("%.2f", disk_util);
}