Skip to content

Commit e275c40

Browse files
committed
FileSpeed Tests
1 parent b687539 commit e275c40

File tree

10 files changed

+248
-148
lines changed

10 files changed

+248
-148
lines changed

examples/tests/performance/file-speeds-sd/file-speeds-sd.ino

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,14 @@ void testFS(const char* name, SD& sd, Open write, Open read) {
6363

6464

6565
void setup() {
66-
6766
Serial.begin(115200);
6867

69-
while (!SD_MMC.begin()) {
70-
Serial.println("SDMMC error");
68+
SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
69+
while (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)) {
70+
Serial.println("SD error");
7171
delay(1000);
7272
}
73-
testFS<fs::SDMMCFS, const char*>("SD_MMC", SD_MMC, FILE_WRITE, FILE_READ);
74-
75-
// SPI.begin(PIN_AUDIO_KIT_SD_CARD_CLK, PIN_AUDIO_KIT_SD_CARD_MISO, PIN_AUDIO_KIT_SD_CARD_MOSI, PIN_AUDIO_KIT_SD_CARD_CS);
76-
// while (!SD.begin(PIN_AUDIO_KIT_SD_CARD_CS)) {
77-
// Serial.println("SD error");
78-
// delay(1000);
79-
// }
80-
// testFS<fs::SDFS, const char*>("SD", SD, FILE_WRITE, FILE_READ);
73+
testFS<fs::SDFS, const char*>("SD", SD, FILE_WRITE, FILE_READ);
8174
}
8275

8376
void loop() {}

examples/tests/performance/file-speeds-sd/result.txt

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,4 @@ Read, SD, 512, 2443, 0.429217
1818
Read, SD, 1024, 2432, 0.431158
1919
Read, SD, 10240, 2423, 0.432759
2020
Read, SD, 102400, 2421, 0.433117
21-
Write, SD_MMC, 1, 10605, 0.098876
22-
Write, SD_MMC, 5, 2384, 0.439839
23-
Write, SD_MMC, 10, 1313, 0.798611
24-
Write, SD_MMC, 25, 728, 1.440352
25-
Write, SD_MMC, 100, 391, 2.681780
26-
Write, SD_MMC, 256, 351, 2.987396
27-
Write, SD_MMC, 512, 313, 3.350083
28-
Write, SD_MMC, 1024, 315, 3.328813
29-
Write, SD_MMC, 10240, 215, 4.877098
30-
Write, SD_MMC, 102400, 109, 9.619963
31-
Read, SD_MMC, 1, 10703, 0.097970
32-
Read, SD_MMC, 5, 2230, 0.470213
33-
Read, SD_MMC, 10, 1171, 0.895453
34-
Read, SD_MMC, 25, 537, 1.952656
35-
Read, SD_MMC, 100, 219, 4.788018
36-
Read, SD_MMC, 256, 155, 6.765007
37-
Read, SD_MMC, 512, 135, 7.767230
38-
Read, SD_MMC, 1024, 124, 8.456258
39-
Read, SD_MMC, 10240, 115, 9.118052
40-
Read, SD_MMC, 102400, 115, 9.118052
21+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include "SPI.h"
2+
#include "SD.h"
3+
#include "SD_MMC.h"
4+
5+
#define PIN_AUDIO_KIT_SD_CARD_CS 13
6+
#define PIN_AUDIO_KIT_SD_CARD_MISO 2
7+
#define PIN_AUDIO_KIT_SD_CARD_MOSI 15
8+
#define PIN_AUDIO_KIT_SD_CARD_CLK 14
9+
10+
uint8_t data[1024 * 100];
11+
int len[] = { 1, 5, 10, 25, 100, 256, 512, 1024, 1024 * 10, 1024 * 100 };
12+
size_t totalSize = 1024 * 1024 * 1;
13+
const char* test_file = "/test.txt";
14+
15+
void testWrite(Stream& file, int writeSize, int totalSize) {
16+
memset(data, 0, sizeof(data));
17+
int32_t start = millis();
18+
while (totalSize > 0) {
19+
int written = file.write(data, min(writeSize, totalSize));
20+
//Serial.println(written);
21+
//assert(written > 0);
22+
totalSize -= written;
23+
}
24+
}
25+
26+
void testRead(Stream& file, int readSize, int totalSize) {
27+
memset(data, 0, sizeof(data));
28+
while (totalSize > 0) {
29+
int read = file.readBytes(data, min(readSize, totalSize));
30+
//assert(read>0);
31+
totalSize -= read;
32+
}
33+
}
34+
35+
void logTime(uint32_t start, int i, const char* name, const char* op) {
36+
int32_t time = millis() - start;
37+
float thru = (float)totalSize / (float)time / 1000.0;
38+
Serial.printf("%s, %s, %d, %d, %f\n", op, name, i, time, thru);
39+
}
40+
41+
template<typename SD, typename Open>
42+
void testFS(const char* name, SD& sd, Open write, Open read) {
43+
44+
for (int i : len) {
45+
int32_t start = millis();
46+
auto file = sd.open(test_file, write);
47+
file.seek(0);
48+
assert(file);
49+
testWrite(file, i, totalSize);
50+
file.close();
51+
logTime(start, i, name, "Write");
52+
}
53+
for (int i : len) {
54+
int32_t start = millis();
55+
auto file = sd.open(test_file, read);
56+
assert(file);
57+
testRead(file, i, totalSize);
58+
file.close();
59+
logTime(start, i, name, "Read");
60+
}
61+
sd.end();
62+
}
63+
64+
65+
void setup() {
66+
Serial.begin(115200);
67+
68+
while (!SD_MMC.begin()) {
69+
Serial.println("SDMMC error");
70+
delay(1000);
71+
}
72+
testFS<fs::SDMMCFS, const char*>("SD_MMC", SD_MMC, FILE_WRITE, FILE_READ);
73+
}
74+
75+
void loop() {}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Write, SD, 1, 12813, 0.081837
2+
Write, SD, 5, 4578, 0.229047
3+
Write, SD, 10, 3550, 0.295374
4+
Write, SD, 25, 2927, 0.358243
5+
Write, SD, 100, 2623, 0.399762
6+
Write, SD, 256, 2607, 0.402216
7+
Write, SD, 512, 2571, 0.407848
8+
Write, SD, 1024, 2601, 0.403143
9+
Write, SD, 10240, 2531, 0.414293
10+
Write, SD, 102400, 2451, 0.427816
11+
Read, SD, 1, 13009, 0.080604
12+
Read, SD, 5, 4538, 0.231066
13+
Read, SD, 10, 3478, 0.301488
14+
Read, SD, 25, 2845, 0.368568
15+
Read, SD, 100, 2527, 0.414949
16+
Read, SD, 256, 2463, 0.425731
17+
Read, SD, 512, 2443, 0.429217
18+
Read, SD, 1024, 2432, 0.431158
19+
Read, SD, 10240, 2423, 0.432759
20+
Read, SD, 102400, 2421, 0.433117
21+
Write, SD_MMC, 1, 10605, 0.098876
22+
Write, SD_MMC, 5, 2384, 0.439839
23+
Write, SD_MMC, 10, 1313, 0.798611
24+
Write, SD_MMC, 25, 728, 1.440352
25+
Write, SD_MMC, 100, 391, 2.681780
26+
Write, SD_MMC, 256, 351, 2.987396
27+
Write, SD_MMC, 512, 313, 3.350083
28+
Write, SD_MMC, 1024, 315, 3.328813
29+
Write, SD_MMC, 10240, 215, 4.877098
30+
Write, SD_MMC, 102400, 109, 9.619963
31+
Read, SD_MMC, 1, 10703, 0.097970
32+
Read, SD_MMC, 5, 2230, 0.470213
33+
Read, SD_MMC, 10, 1171, 0.895453
34+
Read, SD_MMC, 25, 537, 1.952656
35+
Read, SD_MMC, 100, 219, 4.788018
36+
Read, SD_MMC, 256, 155, 6.765007
37+
Read, SD_MMC, 512, 135, 7.767230
38+
Read, SD_MMC, 1024, 124, 8.456258
39+
Read, SD_MMC, 10240, 115, 9.118052
40+
Read, SD_MMC, 102400, 115, 9.118052

examples/tests/performance/file-speeds-vfs/tesult.txt

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#define AUDIOBOARD_SD
2+
#include "AudioTools.h"
3+
#include "AudioTools/Disk/VFS_SDSPI.h"
4+
#include "AudioTools/Disk/VFS_SDMMC.h"
5+
#include "AudioTools/Disk/VFSFile.h"
6+
7+
#define PIN_AUDIO_KIT_SD_CARD_CS 13
8+
#define PIN_AUDIO_KIT_SD_CARD_MISO 2
9+
#define PIN_AUDIO_KIT_SD_CARD_MOSI 15
10+
#define PIN_AUDIO_KIT_SD_CARD_CLK 14
11+
12+
const size_t max_len = 1024 * 100;
13+
uint8_t *data = nullptr;
14+
int len[] = { 1, 5, 10, 25, 100, 256, 512, 1024, 1024 * 10, 1024 * 100 };
15+
size_t totalSize = 1024 * 1024 * 1;
16+
const char* test_file = "/test.txt";
17+
18+
void testWrite(Stream& file, int writeSize, int totalSize) {
19+
memset(data, 0, max_len);
20+
int32_t start = millis();
21+
while (totalSize > 0) {
22+
int written = file.write(data, min(writeSize, totalSize));
23+
//Serial.println(written);
24+
//assert(written > 0);
25+
totalSize -= written;
26+
}
27+
}
28+
29+
void testRead(Stream& file, int readSize, int totalSize) {
30+
memset(data, 0, max_len);
31+
while (totalSize > 0) {
32+
int read = file.readBytes(data, min(readSize, totalSize));
33+
//assert(read>0);
34+
totalSize -= read;
35+
}
36+
}
37+
38+
void logTime(uint32_t start, int i, const char* name, const char* op) {
39+
int32_t time = millis() - start;
40+
float thru = (float)totalSize / (float)time / 1000.0;
41+
Serial.printf("%s, %s, %d, %d, %f\n", op, name, i, time, thru);
42+
}
43+
44+
template<typename SD, typename Open>
45+
void testFS(const char* name, SD& sd, Open write, Open read) {
46+
while (!sd.begin()) {
47+
Serial.print(name);
48+
Serial.println(" error");
49+
delay(1000);
50+
}
51+
52+
for (int i : len) {
53+
int32_t start = millis();
54+
auto file = sd.open(test_file, write);
55+
file.seek(0);
56+
assert(file);
57+
testWrite(file, i, totalSize);
58+
file.close();
59+
logTime(start, i, name, "Write");
60+
}
61+
for (int i : len) {
62+
int32_t start = millis();
63+
auto file = sd.open(test_file, read);
64+
assert(file);
65+
testRead(file, i, totalSize);
66+
file.close();
67+
logTime(start, i, name, "Read");
68+
}
69+
sd.end();
70+
}
71+
72+
void setup() {
73+
Serial.begin(115200);
74+
75+
VFS_SDSPI sd;
76+
//VFS_SDMMC sdmmc;
77+
78+
data = new uint8_t[max_len];
79+
assert(data!=nullptr);
80+
81+
testFS<VFS_SDSPI, FileMode>("VFS_SDSPI", sd, VFS_FILE_WRITE, VFS_FILE_READ);
82+
//testFS<VFS_SDMMC, FileMode>("VFS_SDMMC", sdmmc, VFS_FILE_WRITE, VFS_FILE_READ);
83+
}
84+
85+
void loop() {}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Write, VFS_SDSPI, 1, 3046, 0.344247
2+
Write, VFS_SDSPI, 5, 2949, 0.355570
3+
Write, VFS_SDSPI, 10, 2931, 0.357754
4+
Write, VFS_SDSPI, 25, 2926, 0.358365
5+
Write, VFS_SDSPI, 100, 2920, 0.359101
6+
Write, VFS_SDSPI, 256, 2925, 0.358488
7+
Write, VFS_SDSPI, 512, 2912, 0.360088
8+
Write, VFS_SDSPI, 1024, 2925, 0.358488
9+
Write, VFS_SDSPI, 10240, 2925, 0.358488
10+
Write, VFS_SDSPI, 102400, 2928, 0.358120
11+
Read, VFS_SDSPI, 1, 2500, 0.419430
12+
Read, VFS_SDSPI, 5, 1521, 0.689399
13+
Read, VFS_SDSPI, 10, 1398, 0.750054
14+
Read, VFS_SDSPI, 25, 1324, 0.791976
15+
Read, VFS_SDSPI, 100, 1287, 0.814744
16+
Read, VFS_SDSPI, 256, 1169, 0.896985
17+
Read, VFS_SDSPI, 512, 1127, 0.930413
18+
Read, VFS_SDSPI, 1024, 936, 1.120274
19+
Read, VFS_SDSPI, 10240, 665, 1.576806
20+
Read, VFS_SDSPI, 102400, 639, 1.640964
21+
22+
File renamed without changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
Write, VFS_SDMMC, 1, 2478, 0.423154
3+
Write, VFS_SDMMC, 5, 2363, 0.443748
4+
Write, VFS_SDMMC, 10, 2342, 0.447727
5+
Write, VFS_SDMMC, 25, 2336, 0.448877
6+
Write, VFS_SDMMC, 100, 2331, 0.449840
7+
Write, VFS_SDMMC, 256, 2337, 0.448685
8+
Write, VFS_SDMMC, 512, 2325, 0.451000
9+
Write, VFS_SDMMC, 1024, 2335, 0.449069
10+
Write, VFS_SDMMC, 10240, 2337, 0.448685
11+
Write, VFS_SDMMC, 102400, 2336, 0.448877
12+
Read, VFS_SDMMC, 1, 1808, 0.579965
13+
Read, VFS_SDMMC, 5, 827, 1.267928
14+
Read, VFS_SDMMC, 10, 705, 1.487342
15+
Read, VFS_SDMMC, 25, 631, 1.661769
16+
Read, VFS_SDMMC, 100, 594, 1.765279
17+
Read, VFS_SDMMC, 256, 508, 2.064126
18+
Read, VFS_SDMMC, 512, 467, 2.245345
19+
Read, VFS_SDMMC, 1024, 277, 3.785473
20+
Read, VFS_SDMMC, 10240, 88, 11.915637
21+
Read, VFS_SDMMC, 102400, 69, 15.196754

0 commit comments

Comments
 (0)