0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ESP32-WROOMでの書き込み/読み込み 速度比較

Posted at

#概要
個人的な忘備録的に書いておく。

#結果

  1. DRAM
  • 書き込み: 0.01 us/byte
  • 読み込み: 0.01 us/byte
  1. PSRAM
  • 書き込み: 0.12 us/byte
  • 読み込み: 0.10 us/byte
  1. Queue
  • 書き込み: 1.75 us/byte
  • 読み込み: 1.84 us/byte

検証プログラム

#include <Arduino.h>

#define LENGTH  100000

QueueHandle_t xqueue;


void setup() {
    Serial.begin(115200);
  // put your setup code here, to run once:
    xqueue = xQueueCreate(LENGTH, sizeof(uint8_t));
}

void loop() {
    // put your main code here, to run repeatedly:
    uint8_t data = 0;
    unsigned long t0, t1;
    uint8_t *array = (uint8_t*)malloc(sizeof(uint8_t) * LENGTH);
    uint8_t *parray = (uint8_t*)ps_malloc(sizeof(uint8_t) * LENGTH);

    t0 = micros();
    for (int i = 0; i < LENGTH; i++)
    {
        xQueueSend(xqueue, &data, 0);
    }
    t1 = micros();
    Serial.printf("write: ");
    Serial.println((double)(t1 - t0) / LENGTH);

    t0 = micros();
    for (int i = 0; i < LENGTH; i++)
    {
        array[i] = data;
    }
    t1 = micros();
    Serial.printf("write array: ");
    Serial.println((double)(t1 - t0) / LENGTH);

    t0 = micros();
    for (int i = 0; i < LENGTH; i++)
    {
        data = array[i];
    }
    t1 = micros();
    Serial.printf("read array: ");
    Serial.println((double)(t1 - t0) / LENGTH);

    t0 = micros();
    for (int i = 0; i < LENGTH; i++)
    {
        parray[i] = data;
    }
    t1 = micros();
    Serial.printf("write parray: ");
    Serial.println((double)(t1 - t0) / LENGTH);

    t0 = micros();
    for (int i = 0; i < LENGTH; i++)
    {
        data = parray[i];
    }
    t1 = micros();
    Serial.printf("read parray: ");
    Serial.println((double)(t1 - t0) / LENGTH);

    uint8_t recv;
    t0 = micros();
    for (int i = 0; i < LENGTH; i++)
    {
        xQueueReceive(xqueue, &recv, 0);
    }
    t1 = micros();
    Serial.printf("read: ");
    Serial.println((double)(t1 - t0) / LENGTH);

    free(array);
    free(parray);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?