]> granicus.if.org Git - esp-idf/commitdiff
unit test: Measure test wall time with CCOUNT, so it includes time w/ interrupts off
authorAngus Gratton <angus@espressif.com>
Wed, 22 Mar 2017 03:50:05 +0000 (11:50 +0800)
committerAngus Gratton <angus@espressif.com>
Wed, 22 Mar 2017 07:35:54 +0000 (15:35 +0800)
components/spi_flash/flash_ops.c
tools/unit-test-app/components/unity/unity_platform.c
tools/unit-test-app/main/app_main.c

index 21a77a945b1c2fa75a4e73205f4014856a9cce12..86101ef04770f5fcbdc2bea9775e6dedc7c37492 100644 (file)
@@ -491,7 +491,7 @@ static esp_err_t IRAM_ATTR spi_flash_translate_rc(SpiFlashOpResult rc)
 
 static inline void dump_counter(spi_flash_counter_t* counter, const char* name)
 {
-    ESP_LOGI(TAG, "%s  count=%8d  time=%8dms  bytes=%8d\n", name,
+    ESP_LOGI(TAG, "%s  count=%8d  time=%8dus  bytes=%8d\n", name,
              counter->count, counter->time, counter->bytes);
 }
 
index 05e50a16069eedbf36209f9cfd35602dd1affdae..3f453326cab71d5cfe4389abf4c9c44c9bdfbdc6 100644 (file)
@@ -8,6 +8,7 @@
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "esp_log.h"
+#include "soc/cpu.h"
 
 #define unity_printf ets_printf
 
@@ -167,10 +168,13 @@ void unity_run_menu()
             int test_index = strtol(cmdline, NULL, 10);
             if (test_index >= 1 && test_index <= test_count)
             {
-                uint32_t start = esp_log_timestamp(); /* hacky way to get ms */
+                uint32_t start;
+                RSR(CCOUNT, start);
                 unity_run_single_test_by_index(test_index - 1);
-                uint32_t end = esp_log_timestamp();
-                printf("Test ran in %dms\n", end - start);
+                uint32_t end;
+                RSR(CCOUNT, end);
+                uint32_t ms = (end - start) / (XT_CLOCK_FREQ / 1000);
+                printf("Test ran in %dms\n", ms);
             }
         }
 
index b00034adf1dec563961da4b1be6bb4d2efca5934..58a195172016d2408fcd23bea103080c4022d9d4 100644 (file)
@@ -11,8 +11,10 @@ void unityTask(void *pvParameters)
     while(1);
 }
 
-void app_main() 
+void app_main()
 {
+    // Note: if unpinning this task, change the way run times are calculated in
+    // unity_platform
     xTaskCreatePinnedToCore(unityTask, "unityTask", 4096, NULL, 5, NULL, 0);
 }