You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/10/03 19:07:23 UTC

[incubator-nuttx-apps] branch master updated (0e0ac0656 -> 98a9d2c74)

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

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


    from 0e0ac0656 system/cachespeed:Tools for testing cache-related speed.
     new 744ecf2b0 system/ramspeed: Add system interrupt switch.
     new 98a9d2c74 system/ramspeed: Add system interrupt switch.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 system/ramspeed/ramspeed_main.c | 69 ++++++++++++++++++++++++++++++-----------
 1 file changed, 51 insertions(+), 18 deletions(-)


[incubator-nuttx-apps] 01/02: system/ramspeed: Add system interrupt switch.

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 744ecf2b01fa5e1c4ec774b28fb8b8e32f60ba87
Author: crafcat <11...@users.noreply.github.com>
AuthorDate: Sat Oct 1 22:42:23 2022 +0800

    system/ramspeed: Add system interrupt switch.
---
 system/ramspeed/ramspeed_main.c | 67 ++++++++++++++++++++++++++++++-----------
 1 file changed, 49 insertions(+), 18 deletions(-)

diff --git a/system/ramspeed/ramspeed_main.c b/system/ramspeed/ramspeed_main.c
index f6040dd43..c2485f7e7 100644
--- a/system/ramspeed/ramspeed_main.c
+++ b/system/ramspeed/ramspeed_main.c
@@ -23,6 +23,7 @@
  ****************************************************************************/
 
 #include <nuttx/config.h>
+#include <nuttx/irq.h>
 #include <stdio.h>
 #include <stdint.h>
 #include <stdlib.h>
@@ -74,6 +75,7 @@ struct ramspeed_s
   size_t size;
   uint8_t value;
   uint32_t repeat_num;
+  bool irq_disable;
 };
 
 /****************************************************************************
@@ -91,7 +93,7 @@ struct ramspeed_s
 static void show_usage(FAR const char *progname, int exitcode)
 {
   printf("\nUsage: %s -r <hex-address> -w <hex-address> -s <decimal-size>"
-         " -v <hex-value>[0x00] -n <decimal-repeat number>[100]\n",
+         " -v <hex-value>[0x00] -n <decimal-repeat number>[100] -i\n",
          progname);
   printf("\nWhere:\n");
   printf("  -r <hex-address> read address.\n");
@@ -101,6 +103,8 @@ static void show_usage(FAR const char *progname, int exitcode)
          " [default value: 0x00].\n");
   printf("  -n <decimal-repeat num> number of repetitions"
          " [default value: 100].\n");
+  printf("  -i turn off interrupts while testing"
+         " [default value: false].\n");
   exit(exitcode);
 }
 
@@ -122,7 +126,7 @@ static void parse_commandline(int argc, FAR char **argv,
       show_usage(argv[0], EXIT_FAILURE);
     }
 
-  while ((ch = getopt(argc, argv, "r:w:s:v:n:")) != ERROR)
+  while ((ch = getopt(argc, argv, "r:w:s:v:n:i")) != ERROR)
     {
       switch (ch)
         {
@@ -145,6 +149,9 @@ static void parse_commandline(int argc, FAR char **argv,
                 printf(RAMSPEED_PREFIX "<repeat number> must > 0\n");
                 exit(EXIT_FAILURE);
               }
+
+          case 'i':
+            info->irq_disable = true;
             break;
           case '?':
             printf(RAMSPEED_PREFIX "Unknown option: %c\n", (char)optopt);
@@ -346,12 +353,20 @@ static void print_rate(FAR const char *name, size_t bytes,
  ****************************************************************************/
 
 static void memcpy_speed_test(FAR void *dest, FAR const void *src,
-                              size_t size, uint32_t repeat_cnt)
+                              size_t size, uint32_t repeat_cnt,
+                              bool irq_disable)
 {
   uint32_t start_time;
-  uint32_t cost_time;
+  uint32_t cost_time_system;
+  uint32_t cost_time_internal;
   uint32_t cnt;
   const size_t total_size = size * repeat_cnt;
+  irqstate_t flags;
+
+  if (irq_disable)
+    {
+      flags = enter_critical_section();
+    }
 
   start_time = get_timestamp();
 
@@ -360,9 +375,7 @@ static void memcpy_speed_test(FAR void *dest, FAR const void *src,
       memcpy(dest, src, size);
     }
 
-  cost_time = get_time_elaps(start_time);
-
-  print_rate("system memcpy():\t", total_size, cost_time);
+  cost_time_system = get_time_elaps(start_time);
 
   start_time = get_timestamp();
 
@@ -371,9 +384,15 @@ static void memcpy_speed_test(FAR void *dest, FAR const void *src,
       internal_memcpy(dest, src, size);
     }
 
-  cost_time = get_time_elaps(start_time);
+  cost_time_internal = get_time_elaps(start_time);
+
+  if (irq_disable)
+    {
+      leave_critical_section(flags);
+    }
 
-  print_rate("internal memcpy():\t", total_size, cost_time);
+  print_rate("system memcpy():\t", total_size, cost_time_system);
+  print_rate("internal memcpy():\t", total_size, cost_time_internal);
 }
 
 /****************************************************************************
@@ -381,12 +400,20 @@ static void memcpy_speed_test(FAR void *dest, FAR const void *src,
  ****************************************************************************/
 
 static void memset_speed_test(FAR void *dest, uint8_t value,
-                              size_t size, uint32_t repeat_num)
+                              size_t size, uint32_t repeat_num,
+                              bool irq_disable)
 {
   uint32_t start_time;
-  uint32_t cost_time;
+  uint32_t cost_time_system;
+  uint32_t cost_time_internal;
   uint32_t cnt;
   const size_t total_size = size * repeat_num;
+  irqstate_t flags;
+
+  if (irq_disable)
+    {
+      flags = enter_critical_section();
+    }
 
   start_time = get_timestamp();
 
@@ -395,9 +422,7 @@ static void memset_speed_test(FAR void *dest, uint8_t value,
       memset(dest, value, size);
     }
 
-  cost_time = get_time_elaps(start_time);
-
-  print_rate("system memset():\t", total_size, cost_time);
+  cost_time_system = get_time_elaps(start_time);
 
   start_time = get_timestamp();
 
@@ -406,9 +431,15 @@ static void memset_speed_test(FAR void *dest, uint8_t value,
       internal_memset(dest, value, size);
     }
 
-  cost_time = get_time_elaps(start_time);
+  cost_time_internal = get_time_elaps(start_time);
+
+  if (irq_disable)
+    {
+      leave_critical_section(flags);
+    }
 
-  print_rate("internal memset():\t", total_size, cost_time);
+  print_rate("system memset():\t", total_size, cost_time_system);
+  print_rate("internal memset():\t", total_size, cost_time_internal);
 }
 
 /****************************************************************************
@@ -426,10 +457,10 @@ int main(int argc, FAR char *argv[])
   parse_commandline(argc, argv, &ramspeed);
 
   memcpy_speed_test(ramspeed.dest, ramspeed.src,
-                    ramspeed.size, ramspeed.repeat_num);
+                    ramspeed.size, ramspeed.repeat_num, ramspeed.irq_disable);
 
   memset_speed_test(ramspeed.dest, ramspeed.value,
-                    ramspeed.size, ramspeed.repeat_num);
+                    ramspeed.size, ramspeed.repeat_num, ramspeed.irq_disable);
 
   return EXIT_SUCCESS;
 }


[incubator-nuttx-apps] 02/02: system/ramspeed: Add system interrupt switch.

Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 98a9d2c749a32f3fb0c9879c9e7be5b062f8dadc
Author: crafcat <11...@users.noreply.github.com>
AuthorDate: Sat Oct 1 22:55:56 2022 +0800

    system/ramspeed: Add system interrupt switch.
    
    system/ramspeed: Add system interrupt switch.
---
 system/ramspeed/ramspeed_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/system/ramspeed/ramspeed_main.c b/system/ramspeed/ramspeed_main.c
index c2485f7e7..65c25e22c 100644
--- a/system/ramspeed/ramspeed_main.c
+++ b/system/ramspeed/ramspeed_main.c
@@ -457,10 +457,12 @@ int main(int argc, FAR char *argv[])
   parse_commandline(argc, argv, &ramspeed);
 
   memcpy_speed_test(ramspeed.dest, ramspeed.src,
-                    ramspeed.size, ramspeed.repeat_num, ramspeed.irq_disable);
+                    ramspeed.size, ramspeed.repeat_num,
+                    ramspeed.irq_disable);
 
   memset_speed_test(ramspeed.dest, ramspeed.value,
-                    ramspeed.size, ramspeed.repeat_num, ramspeed.irq_disable);
+                    ramspeed.size, ramspeed.repeat_num,
+                    ramspeed.irq_disable);
 
   return EXIT_SUCCESS;
 }