You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2022/11/12 21:57:11 UTC

[incubator-nuttx-apps] branch master updated: system/ramspeed:Add automated testing process

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 902ae591b system/ramspeed:Add automated testing process
902ae591b is described below

commit 902ae591b117852a26e302b4b4f7cb3d837cb7c5
Author: crafcat7 <11...@users.noreply.github.com>
AuthorDate: Sun Nov 13 01:09:10 2022 +0800

    system/ramspeed:Add automated testing process
    
    In the previous ramspeed test process, it was necessary to keep adding size to achieve speed tests for different sizes of memcpy and memset. After the modification, the results will be automatically looped from 32k to the input size.
---
 system/ramspeed/ramspeed_main.c | 127 ++++++++++++++++++++++++++--------------
 1 file changed, 83 insertions(+), 44 deletions(-)

diff --git a/system/ramspeed/ramspeed_main.c b/system/ramspeed/ramspeed_main.c
index 65c25e22c..6c3507bc7 100644
--- a/system/ramspeed/ramspeed_main.c
+++ b/system/ramspeed/ramspeed_main.c
@@ -138,6 +138,11 @@ static void parse_commandline(int argc, FAR char **argv,
             break;
           case 's':
             OPTARG_TO_VALUE(info->size, size_t, 10);
+            if (info->size < 32)
+              {
+                printf(RAMSPEED_PREFIX "<size> must >= 32");
+                exit(EXIT_FAILURE);
+              }
             break;
           case 'v':
             OPTARG_TO_VALUE(info->value, uint8_t, 16);
@@ -360,39 +365,56 @@ static void memcpy_speed_test(FAR void *dest, FAR const void *src,
   uint32_t cost_time_system;
   uint32_t cost_time_internal;
   uint32_t cnt;
-  const size_t total_size = size * repeat_cnt;
+  uint32_t step;
+  size_t total_size;
   irqstate_t flags;
 
-  if (irq_disable)
+  printf("______memcpy performance______\n");
+
+  for (step = 32; step <= size; step <<= 1)
     {
-      flags = enter_critical_section();
-    }
+      total_size = step * repeat_cnt;
 
-  start_time = get_timestamp();
+      if (step < 1024)
+        {
+          printf("______do %" PRIu32 " B operation______\n", step);
+        }
+      else
+        {
+          printf("______do %" PRIu32  " KB operation______\n", step / 1024);
+        }
 
-  for (cnt = 0; cnt < repeat_cnt; cnt++)
-    {
-      memcpy(dest, src, size);
-    }
+      if (irq_disable)
+        {
+          flags = enter_critical_section();
+        }
 
-  cost_time_system = get_time_elaps(start_time);
+      start_time = get_timestamp();
 
-  start_time = get_timestamp();
+      for (cnt = 0; cnt < repeat_cnt; cnt++)
+        {
+          memcpy(dest, src, step);
+        }
 
-  for (cnt = 0; cnt < repeat_cnt; cnt++)
-    {
-      internal_memcpy(dest, src, size);
-    }
+      cost_time_system = get_time_elaps(start_time);
 
-  cost_time_internal = get_time_elaps(start_time);
+      start_time = get_timestamp();
 
-  if (irq_disable)
-    {
-      leave_critical_section(flags);
-    }
+      for (cnt = 0; cnt < repeat_cnt; cnt++)
+        {
+          internal_memcpy(dest, src, step);
+        }
+
+      cost_time_internal = get_time_elaps(start_time);
+
+      if (irq_disable)
+        {
+          leave_critical_section(flags);
+        }
 
-  print_rate("system memcpy():\t", total_size, cost_time_system);
-  print_rate("internal memcpy():\t", total_size, cost_time_internal);
+      print_rate("system memcpy():\t", total_size, cost_time_system);
+      print_rate("internal memcpy():\t", total_size, cost_time_internal);
+    }
 }
 
 /****************************************************************************
@@ -407,39 +429,56 @@ static void memset_speed_test(FAR void *dest, uint8_t value,
   uint32_t cost_time_system;
   uint32_t cost_time_internal;
   uint32_t cnt;
-  const size_t total_size = size * repeat_num;
+  uint32_t step;
+  size_t total_size;
   irqstate_t flags;
 
-  if (irq_disable)
+  printf("______memset performance______\n");
+
+  for (step = 32; step <= size; step <<= 1)
     {
-      flags = enter_critical_section();
-    }
+      total_size = step * repeat_num;
+
+      if (step < 1024)
+        {
+          printf("______do %" PRIu32 " B operation______\n", step);
+        }
+      else
+        {
+          printf("______do %" PRIu32  " KB operation______\n", step / 1024);
+        }
 
-  start_time = get_timestamp();
+      if (irq_disable)
+        {
+          flags = enter_critical_section();
+        }
 
-  for (cnt = 0; cnt < repeat_num; cnt++)
-    {
-      memset(dest, value, size);
-    }
+      start_time = get_timestamp();
 
-  cost_time_system = get_time_elaps(start_time);
+      for (cnt = 0; cnt < repeat_num; cnt++)
+        {
+          memset(dest, value, step);
+        }
 
-  start_time = get_timestamp();
+      cost_time_system = get_time_elaps(start_time);
 
-  for (cnt = 0; cnt < repeat_num; cnt++)
-    {
-      internal_memset(dest, value, size);
-    }
+      start_time = get_timestamp();
+
+      for (cnt = 0; cnt < repeat_num; cnt++)
+        {
+          internal_memset(dest, value, step);
+        }
 
-  cost_time_internal = get_time_elaps(start_time);
+      cost_time_internal = get_time_elaps(start_time);
 
-  if (irq_disable)
-    {
-      leave_critical_section(flags);
-    }
+      if (irq_disable)
+        {
+          leave_critical_section(flags);
+        }
 
-  print_rate("system memset():\t", total_size, cost_time_system);
-  print_rate("internal memset():\t", total_size, cost_time_internal);
+      print_rate("system memset():\t", total_size, cost_time_system);
+      print_rate("internal memset():\t", total_size, cost_time_internal);
+    }
 }
 
 /****************************************************************************