]> granicus.if.org Git - esp-idf/commitdiff
test: collect performance for esp-timer / spinlock
authorHe Yin Ling <heyinling@espressif.com>
Mon, 13 Nov 2017 08:58:46 +0000 (16:58 +0800)
committerHe Yin Ling <heyinling@espressif.com>
Thu, 16 Nov 2017 09:48:48 +0000 (17:48 +0800)
components/esp32/test/test_esp_timer.c
components/freertos/test/test_spinlocks.c

index 061b86aa4924ed098920d13c666371de91eee734..08fdb15dc7fcab1fc09ef51d83a82c2e9214b8cb 100644 (file)
@@ -9,6 +9,7 @@
 #include "freertos/semphr.h"
 #include "test_utils.h"
 
+
 TEST_CASE("esp_timer orders timers correctly", "[esp_timer]")
 {
     void dummy_cb(void* arg)
@@ -335,8 +336,7 @@ TEST_CASE("esp_timer_get_time call takes less than 1us", "[esp_timer]")
         end = esp_timer_get_time();
     }
     int ns_per_call = (int) ((end - begin) * 1000 / iter_count);
-    printf("esp_timer_get_time: %dns per call\n", ns_per_call);
-    TEST_ASSERT(ns_per_call < 1000);
+    TEST_PERFORMANCE_LESS_THAN(ESP_TIMER_GET_TIME_PER_CALL, "%dns", ns_per_call);
 }
 
 /* This test runs for about 10 minutes and is disabled in CI.
index 68880ce93601e217a9dbfca24c4fe2890079bdc0..38a87f4a7147b3e993d98ba3a6fe3d95c83122dd 100644 (file)
@@ -17,6 +17,8 @@
 #include "soc/io_mux_reg.h"
 #include "soc/cpu.h"
 
+#include "idf_performance.h"
+
 #define REPEAT_OPS 10000
 
 static uint32_t start, end;
@@ -42,6 +44,12 @@ TEST_CASE("portMUX spinlocks (no contention)", "[freertos]")
         portEXIT_CRITICAL(&mux);
     }
     BENCHMARK_END("no contention lock");
+
+#ifdef CONFIG_FREERTOS_UNICORE
+    TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP_UNICORE, "%d cycles/op", ((end - start)/REPEAT_OPS));
+#else
+    TEST_PERFORMANCE_LESS_THAN(FREERTOS_SPINLOCK_CYCLES_PER_OP, "%d cycles/op", ((end - start)/REPEAT_OPS));
+#endif
 }
 
 TEST_CASE("portMUX recursive locks (no contention)", "[freertos]")