#概要
個人的な忘備録的に書いておく。
#結果
- DRAM
- 書き込み: 0.01 us/byte
- 読み込み: 0.01 us/byte
- PSRAM
- 書き込み: 0.12 us/byte
- 読み込み: 0.10 us/byte
- 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);
}