DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] test: provide performance difference ratio and test time
@ 2017-10-25  7:13 Herbert Guan
  2017-10-26  6:23 ` Jianbo Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Herbert Guan @ 2017-10-25  7:13 UTC (permalink / raw)
  To: dev, bruce.richardson, konstantin.ananyev
  Cc: herbert.guan, jianbo.liu, phil.yang

The printed time values presented in TSC is not straight forward
showing the performance difference.  And if the high resolution
counter is not enabled, time value is too small to show the actual
performance (e.g. "1 - 1" seems the same but in fact the perfomance
diffs by 50% or more).
With the performance difference ratio caculated and printed, it'll be
easier for people to read and compare the performance between
rte_memcpy() and memcpy().
Since the TSC values' units may diff a lot on different platforms,
the total execution time of aligned/unaligned memcpy test are
provided to allow comparation between platforms.

Signed-off-by: Herbert Guan <herbert.guan@arm.com>
---
 test/test/test_memcpy_perf.c | 50 +++++++++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 12 deletions(-)

diff --git a/test/test/test_memcpy_perf.c b/test/test/test_memcpy_perf.c
index 91de856..b23026b 100644
--- a/test/test/test_memcpy_perf.c
+++ b/test/test/test_memcpy_perf.c
@@ -35,6 +35,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <sys/time.h>
 
 #include <rte_common.h>
 #include <rte_cycles.h>
@@ -241,8 +242,9 @@
             memcpy(dst+dst_addrs[t], src+src_addrs[t], size);               \
         total_time2 += rte_rdtsc() - start_time;                            \
     }                                                                       \
-    printf("%8.0f -",  (double)total_time /TEST_ITERATIONS);                \
-    printf("%5.0f",  (double)total_time2 / TEST_ITERATIONS);                \
+    printf("%3.0f -",  (double)total_time / TEST_ITERATIONS);                \
+    printf("%3.0f",  (double)total_time2 / TEST_ITERATIONS);                \
+    printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2);  \
 } while (0)
 
 /* Run aligned memcpy tests for each cached/uncached permutation */
@@ -324,6 +326,9 @@
 perf_test(void)
 {
 	int ret;
+	struct timeval tv_begin, tv_end;
+	double time_aligned, time_unaligned;
+	double time_aligned_const, time_unaligned_const;
 
 	ret = init_buffers();
 	if (ret != 0)
@@ -340,26 +345,47 @@
 	do_uncached_write(large_buf_write, 0, small_buf_read, 1, SMALL_BUFFER_SIZE);
 
 	printf("\n** rte_memcpy() - memcpy perf. tests (C = compile-time constant) **\n"
-		   "======= ============== ============== ============== ==============\n"
-		   "   Size Cache to cache   Cache to mem   Mem to cache     Mem to mem\n"
-		   "(bytes)        (ticks)        (ticks)        (ticks)        (ticks)\n"
-		   "------- -------------- -------------- -------------- --------------");
+		   "======= ================= ================= ================= =================\n"
+		   "   Size   Cache to cache     Cache to mem      Mem to cache        Mem to mem\n"
+		   "(bytes)          (ticks)          (ticks)           (ticks)           (ticks)\n"
+		   "------- ----------------- ----------------- ----------------- -----------------");
 
-	printf("\n========================= %2dB aligned ============================",
+	printf("\n================================= %2dB aligned =================================",
 		alignment_unit);
 	/* Do aligned tests where size is a variable */
+	gettimeofday(&tv_begin, NULL);
 	perf_test_variable_aligned();
-	printf("\n------- -------------- -------------- -------------- --------------");
+	gettimeofday(&tv_end, NULL);
+	time_aligned = (double)(tv_end.tv_sec - tv_begin.tv_sec)
+		+ ((double)tv_end.tv_usec - tv_begin.tv_usec)/1000000;
+	printf("\n------- ----------------- ----------------- ----------------- -----------------");
 	/* Do aligned tests where size is a compile-time constant */
+	gettimeofday(&tv_begin, NULL);
 	perf_test_constant_aligned();
-	printf("\n=========================== Unaligned =============================");
+	gettimeofday(&tv_end, NULL);
+	time_aligned_const = (double)(tv_end.tv_sec - tv_begin.tv_sec)
+		+ ((double)tv_end.tv_usec - tv_begin.tv_usec)/1000000;
+	printf("\n================================== Unaligned ==================================");
 	/* Do unaligned tests where size is a variable */
+	gettimeofday(&tv_begin, NULL);
 	perf_test_variable_unaligned();
-	printf("\n------- -------------- -------------- -------------- --------------");
+	gettimeofday(&tv_end, NULL);
+	time_unaligned = (double)(tv_end.tv_sec - tv_begin.tv_sec)
+		+ ((double)tv_end.tv_usec - tv_begin.tv_usec)/1000000;
+	printf("\n------- ----------------- ----------------- ----------------- -----------------");
 	/* Do unaligned tests where size is a compile-time constant */
+	gettimeofday(&tv_begin, NULL);
 	perf_test_constant_unaligned();
-	printf("\n======= ============== ============== ============== ==============\n\n");
-
+	gettimeofday(&tv_end, NULL);
+	time_unaligned_const = (double)(tv_end.tv_sec - tv_begin.tv_sec)
+		+ ((double)tv_end.tv_usec - tv_begin.tv_usec)/1000000;
+	printf("\n======= ================= ================= ================= =================\n\n");
+
+	printf("Test Execution Time (seconds):\n");
+	printf("Aligned variable copy size   = %8.3f\n", time_aligned);
+	printf("Aligned constant copy size   = %8.3f\n", time_aligned_const);
+	printf("Unaligned variable copy size = %8.3f\n", time_unaligned);
+	printf("Unaligned constant copy size = %8.3f\n", time_unaligned_const);
 	free_buffers();
 
 	return 0;
-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] test: provide performance difference ratio and test time
  2017-10-25  7:13 [dpdk-dev] [PATCH] test: provide performance difference ratio and test time Herbert Guan
@ 2017-10-26  6:23 ` Jianbo Liu
  2017-11-07 17:20   ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Jianbo Liu @ 2017-10-26  6:23 UTC (permalink / raw)
  To: Herbert Guan; +Cc: dev, bruce.richardson, konstantin.ananyev, phil.yang

The 10/25/2017 15:13, Herbert Guan wrote:
> The printed time values presented in TSC is not straight forward
> showing the performance difference.  And if the high resolution
> counter is not enabled, time value is too small to show the actual
> performance (e.g. "1 - 1" seems the same but in fact the perfomance
> diffs by 50% or more).
> With the performance difference ratio caculated and printed, it'll be
> easier for people to read and compare the performance between
> rte_memcpy() and memcpy().
> Since the TSC values' units may diff a lot on different platforms,
> the total execution time of aligned/unaligned memcpy test are
> provided to allow comparation between platforms.
>
> Signed-off-by: Herbert Guan <herbert.guan@arm.com>

Acked-by: Jianbo Liu <jianbo.liu@arm.com>

> ---
>  test/test/test_memcpy_perf.c | 50 +++++++++++++++++++++++++++++++++-----------
>  1 file changed, 38 insertions(+), 12 deletions(-)
>
> diff --git a/test/test/test_memcpy_perf.c b/test/test/test_memcpy_perf.c
> index 91de856..b23026b 100644
> --- a/test/test/test_memcpy_perf.c
> +++ b/test/test/test_memcpy_perf.c
> @@ -35,6 +35,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <stdlib.h>
> +#include <sys/time.h>
>
>  #include <rte_common.h>
>  #include <rte_cycles.h>
> @@ -241,8 +242,9 @@
>              memcpy(dst+dst_addrs[t], src+src_addrs[t], size);               \
>          total_time2 += rte_rdtsc() - start_time;                            \
>      }                                                                       \
> -    printf("%8.0f -",  (double)total_time /TEST_ITERATIONS);                \
> -    printf("%5.0f",  (double)total_time2 / TEST_ITERATIONS);                \
> +    printf("%3.0f -",  (double)total_time / TEST_ITERATIONS);                \
> +    printf("%3.0f",  (double)total_time2 / TEST_ITERATIONS);                \
> +    printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2);  \
>  } while (0)
>
>  /* Run aligned memcpy tests for each cached/uncached permutation */
> @@ -324,6 +326,9 @@
>  perf_test(void)
>  {
>       int ret;
> +     struct timeval tv_begin, tv_end;
> +     double time_aligned, time_unaligned;
> +     double time_aligned_const, time_unaligned_const;
>
>       ret = init_buffers();
>       if (ret != 0)
> @@ -340,26 +345,47 @@
>       do_uncached_write(large_buf_write, 0, small_buf_read, 1, SMALL_BUFFER_SIZE);
>
>       printf("\n** rte_memcpy() - memcpy perf. tests (C = compile-time constant) **\n"
> -                "======= ============== ============== ============== ==============\n"
> -                "   Size Cache to cache   Cache to mem   Mem to cache     Mem to mem\n"
> -                "(bytes)        (ticks)        (ticks)        (ticks)        (ticks)\n"
> -                "------- -------------- -------------- -------------- --------------");
> +                "======= ================= ================= ================= =================\n"
> +                "   Size   Cache to cache     Cache to mem      Mem to cache        Mem to mem\n"
> +                "(bytes)          (ticks)          (ticks)           (ticks)           (ticks)\n"
> +                "------- ----------------- ----------------- ----------------- -----------------");
>
> -     printf("\n========================= %2dB aligned ============================",
> +     printf("\n================================= %2dB aligned =================================",
>               alignment_unit);
>       /* Do aligned tests where size is a variable */
> +     gettimeofday(&tv_begin, NULL);
>       perf_test_variable_aligned();
> -     printf("\n------- -------------- -------------- -------------- --------------");
> +     gettimeofday(&tv_end, NULL);
> +     time_aligned = (double)(tv_end.tv_sec - tv_begin.tv_sec)
> +             + ((double)tv_end.tv_usec - tv_begin.tv_usec)/1000000;
> +     printf("\n------- ----------------- ----------------- ----------------- -----------------");
>       /* Do aligned tests where size is a compile-time constant */
> +     gettimeofday(&tv_begin, NULL);
>       perf_test_constant_aligned();
> -     printf("\n=========================== Unaligned =============================");
> +     gettimeofday(&tv_end, NULL);
> +     time_aligned_const = (double)(tv_end.tv_sec - tv_begin.tv_sec)
> +             + ((double)tv_end.tv_usec - tv_begin.tv_usec)/1000000;
> +     printf("\n================================== Unaligned ==================================");
>       /* Do unaligned tests where size is a variable */
> +     gettimeofday(&tv_begin, NULL);
>       perf_test_variable_unaligned();
> -     printf("\n------- -------------- -------------- -------------- --------------");
> +     gettimeofday(&tv_end, NULL);
> +     time_unaligned = (double)(tv_end.tv_sec - tv_begin.tv_sec)
> +             + ((double)tv_end.tv_usec - tv_begin.tv_usec)/1000000;
> +     printf("\n------- ----------------- ----------------- ----------------- -----------------");
>       /* Do unaligned tests where size is a compile-time constant */
> +     gettimeofday(&tv_begin, NULL);
>       perf_test_constant_unaligned();
> -     printf("\n======= ============== ============== ============== ==============\n\n");
> -
> +     gettimeofday(&tv_end, NULL);
> +     time_unaligned_const = (double)(tv_end.tv_sec - tv_begin.tv_sec)
> +             + ((double)tv_end.tv_usec - tv_begin.tv_usec)/1000000;
> +     printf("\n======= ================= ================= ================= =================\n\n");
> +
> +     printf("Test Execution Time (seconds):\n");
> +     printf("Aligned variable copy size   = %8.3f\n", time_aligned);
> +     printf("Aligned constant copy size   = %8.3f\n", time_aligned_const);
> +     printf("Unaligned variable copy size = %8.3f\n", time_unaligned);
> +     printf("Unaligned constant copy size = %8.3f\n", time_unaligned_const);
>       free_buffers();
>
>       return 0;
> --
> 1.8.3.1
>

--
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] test: provide performance difference ratio and test time
  2017-10-26  6:23 ` Jianbo Liu
@ 2017-11-07 17:20   ` Thomas Monjalon
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2017-11-07 17:20 UTC (permalink / raw)
  To: Herbert Guan
  Cc: dev, Jianbo Liu, bruce.richardson, konstantin.ananyev, phil.yang

26/10/2017 08:23, Jianbo Liu:
> The 10/25/2017 15:13, Herbert Guan wrote:
> > The printed time values presented in TSC is not straight forward
> > showing the performance difference.  And if the high resolution
> > counter is not enabled, time value is too small to show the actual
> > performance (e.g. "1 - 1" seems the same but in fact the perfomance
> > diffs by 50% or more).
> > With the performance difference ratio caculated and printed, it'll be
> > easier for people to read and compare the performance between
> > rte_memcpy() and memcpy().
> > Since the TSC values' units may diff a lot on different platforms,
> > the total execution time of aligned/unaligned memcpy test are
> > provided to allow comparation between platforms.
> >
> > Signed-off-by: Herbert Guan <herbert.guan@arm.com>
> 
> Acked-by: Jianbo Liu <jianbo.liu@arm.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] test: provide performance difference ratio and test time
       [not found] <1508726101-13009-1-git-send-email-herbert.guan@arm.com>
@ 2017-10-24  2:58 ` Jianbo Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Jianbo Liu @ 2017-10-24  2:58 UTC (permalink / raw)
  To: Herbert Guan; +Cc: dev, bruce.richardson, konstantin.ananyev, phil.yang

Hi Herbert,

The 10/23/2017 10:35, Herbert Guan wrote:
> The printed time values presented in TSC is not straight forward
> showing the performance difference.  And if the high resolution
> counter is not enabled, time value is too small to show the actual
> performance (e.g. "1 - 1" seems the same but in fact the perfomance
> diffs by 50% or more).
> With the performance difference ratio caculated and printed, it'll be
> easier for people to read and compare the performance between
> rte_memcpy() and memcpy().
> Since the TSC values' units may diff a lot on different platforms,
> the total execution time of alligned/unaligned memcpy test are
> provided to allow comparation between platforms.
>
> Signed-off-by: Herbert Guan <herbert.guan@arm.com>
> ---
>  test/test/test_memcpy_perf.c | 34 +++++++++++++++++++++++-----------
>  1 file changed, 23 insertions(+), 11 deletions(-)
>
> diff --git a/test/test/test_memcpy_perf.c b/test/test/test_memcpy_perf.c
> index 91de856..30c29e1 100644
> --- a/test/test/test_memcpy_perf.c
> +++ b/test/test/test_memcpy_perf.c
> @@ -35,6 +35,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <stdlib.h>
> +#include <sys/time.h>
>
>  #include <rte_common.h>
>  #include <rte_cycles.h>
> @@ -241,8 +242,9 @@
>              memcpy(dst+dst_addrs[t], src+src_addrs[t], size);               \
>          total_time2 += rte_rdtsc() - start_time;                            \
>      }                                                                       \
> -    printf("%8.0f -",  (double)total_time /TEST_ITERATIONS);                \
> -    printf("%5.0f",  (double)total_time2 / TEST_ITERATIONS);                \
> +    printf("%3.0f -",  (double)total_time /TEST_ITERATIONS);                \
> +    printf("%3.0f",  (double)total_time2 / TEST_ITERATIONS);                \
> +    printf("(%6.2f%%) ", ((double)total_time - total_time2)*100/total_time2);  \
>  } while (0)
>
>  /* Run aligned memcpy tests for each cached/uncached permutation */
> @@ -324,6 +326,8 @@
>  perf_test(void)
>  {
>       int ret;
> +     struct timeval tv_begin, tv_end;
> +     time_t time_aligned, time_unaligned;
>
>       ret = init_buffers();
>       if (ret != 0)
> @@ -340,26 +344,34 @@
>       do_uncached_write(large_buf_write, 0, small_buf_read, 1, SMALL_BUFFER_SIZE);
>
>       printf("\n** rte_memcpy() - memcpy perf. tests (C = compile-time constant) **\n"
> -                "======= ============== ============== ============== ==============\n"
> -                "   Size Cache to cache   Cache to mem   Mem to cache     Mem to mem\n"
> -                "(bytes)        (ticks)        (ticks)        (ticks)        (ticks)\n"
> -                "------- -------------- -------------- -------------- --------------");
> +                "======= ================= ================= ================= =================\n"
> +                "   Size   Cache to cache     Cache to mem      Mem to cache        Mem to mem\n"
> +                "(bytes)          (ticks)          (ticks)           (ticks)           (ticks)\n"
> +                "------- ----------------- ----------------- ----------------- -----------------");
>
> -     printf("\n========================= %2dB aligned ============================",
> +     printf("\n================================= %2dB aligned =================================",
>               alignment_unit);
>       /* Do aligned tests where size is a variable */
> +     gettimeofday(&tv_begin, NULL);
>       perf_test_variable_aligned();
> -     printf("\n------- -------------- -------------- -------------- --------------");
> +     gettimeofday(&tv_end, NULL);
> +     time_aligned = tv_end.tv_sec - tv_begin.tv_sec;
> +     printf("\n------- ----------------- ----------------- ----------------- -----------------");
>       /* Do aligned tests where size is a compile-time constant */
>       perf_test_constant_aligned();
> -     printf("\n=========================== Unaligned =============================");
> +     printf("\n================================== Unaligned ==================================");
>       /* Do unaligned tests where size is a variable */
> +     gettimeofday(&tv_begin, NULL);
>       perf_test_variable_unaligned();
> -     printf("\n------- -------------- -------------- -------------- --------------");
> +     gettimeofday(&tv_end, NULL);
> +     time_unaligned = tv_end.tv_sec - tv_begin.tv_sec;
> +     printf("\n------- ----------------- ----------------- ----------------- -----------------");
>       /* Do unaligned tests where size is a compile-time constant */
>       perf_test_constant_unaligned();
> -     printf("\n======= ============== ============== ============== ==============\n\n");
> +     printf("\n======= ================= ================= ================= =================\n\n");
>
> +     printf("Test Execution Time (Aligned)   = %ld seconds\n", time_aligned);
> +     printf("Test Execution Time (Unaligned) = %ld seconds\n", time_unaligned);

Is there any reason why you didn't include the time cost in constant aligned/unaligned cases?

Thanks!
Jianbo

>       free_buffers();
>
>       return 0;
> --
> 1.8.3.1
>

--
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-07 17:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-25  7:13 [dpdk-dev] [PATCH] test: provide performance difference ratio and test time Herbert Guan
2017-10-26  6:23 ` Jianbo Liu
2017-11-07 17:20   ` Thomas Monjalon
     [not found] <1508726101-13009-1-git-send-email-herbert.guan@arm.com>
2017-10-24  2:58 ` Jianbo Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).