From bd2697e6b08fe2435b854e48116e193e4de4b8c3 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Tue, 17 Jan 2017 10:59:34 +0800 Subject: [PATCH] ioat, kperf: fix the testing output. The previous performance caculation is wrong, which is smaller than the per channel performance, so fix it with the average performance data. Change-Id: I40580e5f70fb4273fa080bbdfb17ce85436446aa Signed-off-by: Ziye Yang --- examples/ioat/kperf/ioat_kperf.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/examples/ioat/kperf/ioat_kperf.c b/examples/ioat/kperf/ioat_kperf.c index 390b3efbc..033f0a5ac 100644 --- a/examples/ioat/kperf/ioat_kperf.c +++ b/examples/ioat/kperf/ioat_kperf.c @@ -39,6 +39,8 @@ #include #include +#define ioat_max(a,b) (((a)>(b))?(a):(b)) + static int check_modules(char *driver_name) { @@ -331,26 +333,31 @@ int main(int argc, char *argv[]) sprintf(channel, "/sys/kernel/debug/dmaperf/dmaperf/thread_%u/copied", i); rc = get_u64_from_file(channel, &copied); if (rc < 0) { - fprintf(stderr, "Cannot get channel copied bytes\n"); + fprintf(stderr, "Cannot get channel copied data\n"); return -1; } /* time in microseconds for total data transfer length */ sprintf(channel, "/sys/kernel/debug/dmaperf/dmaperf/thread_%u/elapsed_time", i); + /* elapsed_time is in microsecond */ rc = get_u64_from_file(channel, &elapsed_time); if (rc < 0) { fprintf(stderr, "Cannot get channel elapsed time\n"); return -1; } assert(elapsed_time != 0); - perf = copied / elapsed_time; + perf = (copied * 1000 * 1000) / (elapsed_time * 1024 * 1024); total_copied += copied; - total_time += elapsed_time; - fprintf(stdout, "Channel %d Performance Data %"PRIu64" MB/s\n", + total_time = ioat_max(elapsed_time, total_time); + fprintf(stdout, "Channel %d Bandwidth %"PRIu64" MiB/s\n", i, perf); } - if (total_time && threads) - fprintf(stdout, "Total Channel Performance Data %"PRIu64" MB/s\n", - total_copied / total_time / threads); + if (total_time && threads) { + fprintf(stdout, "Total Channel Bandwidth: %"PRIu64" MiB/s\n", + total_copied / total_time); + fprintf(stdout, "Average Bandwidth Per Channel: %"PRIu64" MiB/s\n", + (total_copied * 1000 * 1000) / (total_time * threads * 1024 * 1024)); + } + return 0; }