This commit is contained in:
2026-02-12 21:00:02 -08:00
parent cb1f2b0efd
commit 40714a3a68
1141 changed files with 1010880 additions and 2 deletions

View File

@@ -0,0 +1,78 @@
#define AUDIOBOARD_SD
#include "AudioTools.h"
#include "AudioTools/Disk/VFSFile.h"
#include "AudioTools/Disk/VFS_SDMMC.h"
const size_t max_len = 1024 * 100;
uint8_t *data = nullptr;
int len[] = { 1, 5, 10, 25, 100, 256, 512, 1024, 1024 * 10, 1024 * 100 };
size_t totalSize = 1024 * 1024 * 1;
const char* test_file = "/test.txt";
void testWrite(Stream& file, int writeSize, int totalSize) {
memset(data, 0, max_len);
int32_t start = millis();
while (totalSize > 0) {
int written = file.write(data, min(writeSize, totalSize));
//Serial.println(written);
//assert(written > 0);
totalSize -= written;
}
}
void testRead(Stream& file, int readSize, int totalSize) {
memset(data, 0, max_len);
while (totalSize > 0) {
int read = file.readBytes(data, min(readSize, totalSize));
//assert(read>0);
totalSize -= read;
}
}
void logTime(uint32_t start, int i, const char* name, const char* op) {
int32_t time = millis() - start;
float thru = (float)totalSize / (float)time / 1000.0;
Serial.printf("%s, %s, %d, %d, %f\n", op, name, i, time, thru);
}
template<typename SD, typename Open>
void testFS(const char* name, SD& sd, Open write, Open read) {
while (!sd.begin()) {
Serial.print(name);
Serial.println(" error");
delay(1000);
}
for (int i : len) {
int32_t start = millis();
auto file = sd.open(test_file, write);
file.seek(0);
assert(file);
testWrite(file, i, totalSize);
file.close();
logTime(start, i, name, "Write");
}
for (int i : len) {
int32_t start = millis();
auto file = sd.open(test_file, read);
assert(file);
testRead(file, i, totalSize);
file.close();
logTime(start, i, name, "Read");
}
sd.end();
}
void setup() {
Serial.begin(115200);
VFS_SDMMC sdmmc;
data = new uint8_t[max_len];
assert(data!=nullptr);
// testFS<VFS_SDSPI, FileMode>("VFS_SDSPI", sd, VFS_FILE_WRITE, VFS_FILE_READ);
testFS<VFS_SDMMC, FileMode>("VFS_SDMMC", sdmmc, VFS_FILE_WRITE, VFS_FILE_READ);
}
void loop() {}

View File

@@ -0,0 +1,21 @@
Write, VFS_SDMMC, 1, 2478, 0.423154
Write, VFS_SDMMC, 5, 2363, 0.443748
Write, VFS_SDMMC, 10, 2342, 0.447727
Write, VFS_SDMMC, 25, 2336, 0.448877
Write, VFS_SDMMC, 100, 2331, 0.449840
Write, VFS_SDMMC, 256, 2337, 0.448685
Write, VFS_SDMMC, 512, 2325, 0.451000
Write, VFS_SDMMC, 1024, 2335, 0.449069
Write, VFS_SDMMC, 10240, 2337, 0.448685
Write, VFS_SDMMC, 102400, 2336, 0.448877
Read, VFS_SDMMC, 1, 1808, 0.579965
Read, VFS_SDMMC, 5, 827, 1.267928
Read, VFS_SDMMC, 10, 705, 1.487342
Read, VFS_SDMMC, 25, 631, 1.661769
Read, VFS_SDMMC, 100, 594, 1.765279
Read, VFS_SDMMC, 256, 508, 2.064126
Read, VFS_SDMMC, 512, 467, 2.245345
Read, VFS_SDMMC, 1024, 277, 3.785473
Read, VFS_SDMMC, 10240, 88, 11.915637
Read, VFS_SDMMC, 102400, 69, 15.196754