From 1db953e0c3e096f9e7ff442f6c50dece002df6e1 Mon Sep 17 00:00:00 2001 From: sheinz Date: Fri, 15 Jul 2016 00:08:34 +0300 Subject: [PATCH] SPIFFS: Add speed test. --- examples/posix_fs/fs-test | 2 +- examples/posix_fs/posix_fs_example.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/posix_fs/fs-test b/examples/posix_fs/fs-test index 12b1023..2ad547a 160000 --- a/examples/posix_fs/fs-test +++ b/examples/posix_fs/fs-test @@ -1 +1 @@ -Subproject commit 12b10230cc56970857e6890bdd5663fbae74c4c3 +Subproject commit 2ad547adc5f725594b3c6752f036ff4401b221fc diff --git a/examples/posix_fs/posix_fs_example.c b/examples/posix_fs/posix_fs_example.c index d84be5e..4525be3 100644 --- a/examples/posix_fs/posix_fs_example.c +++ b/examples/posix_fs/posix_fs_example.c @@ -1,5 +1,6 @@ #include "espressif/esp_common.h" #include "esp/uart.h" +#include "esp/timer.h" #include "FreeRTOS.h" #include "task.h" #include "esp8266.h" @@ -10,6 +11,10 @@ #include "fs-test/fs_test.h" +static fs_time_t get_current_time() +{ + return timer_get_count(FRC2) / 5000; // to get roughly 1ms resolution +} void test_task(void *pvParameters) { @@ -24,12 +29,20 @@ void test_task(void *pvParameters) while (1) { vTaskDelay(5000 / portTICK_RATE_MS); - - if (fs_test_run(1000)) { + if (fs_load_test_run(100)) { printf("PASS\n"); } else { printf("FAIL\n"); } + + vTaskDelay(5000 / portTICK_RATE_MS); + float write_rate, read_rate; + if (fs_speed_test_run(get_current_time, &write_rate, &read_rate)) { + printf("Read speed: %.0f bytes/s\n", read_rate * 1000); + printf("Write speed: %.0f bytes/s\n", write_rate * 1000); + } else { + printf("FAIL\n"); + } } }