Przeglądaj źródła

Faster SdBaseFile::printField()

main
Bill Greiman 10 lat temu
rodzic
commit
565b3eae42
3 zmienionych plików z 37 dodań i 13 usunięć
  1. +4
    -0
      SdFat/SdBaseFilePrint.cpp
  2. +29
    -13
      SdFat/examples/PrintBenchmark/PrintBenchmark.ino
  3. +4
    -0
      changes.txt

+ 4
- 0
SdFat/SdBaseFilePrint.cpp Wyświetl plik

@@ -207,11 +207,15 @@ static int printFieldT(SdBaseFile* file, char sign, Type value, char term) {
*--str = '\r';
}
}
#ifdef OLD_FMT
do {
Type m = value;
value /= 10;
*--str = '0' + m - 10*value;
} while (value);
#else // OLD_FMT
str = fmtDec(value, str);
#endif // OLD_FMT
if (sign) {
*--str = sign;
}

+ 29
- 13
SdFat/examples/PrintBenchmark/PrintBenchmark.ino Wyświetl plik

@@ -50,15 +50,19 @@ void loop() {

cout << pstr("Type is FAT") << int(sd.vol()->fatType()) << endl;

// open or create file - truncate existing file.
if (!file.open("BENCH.TXT", O_CREAT | O_TRUNC | O_RDWR)) {
error("open failed");
}
cout << pstr("Starting print test. Please wait.\n\n");

// do write test
for (int test = 0; test < 3; test++) {

for (int test = 0; test < 5; test++) {
char fileName[13] = "BENCH0.TXT";
fileName[5] = '0' + test;
// open or create file - truncate existing file.
if (!file.open(fileName, O_CREAT | O_TRUNC | O_RDWR)) {
error("open failed");
}
maxLatency = 0;
minLatency = 999999;
totalLatency = 0;
switch(test) {
case 0:
cout << pstr("Test of println(uint16_t)\n");
@@ -69,13 +73,18 @@ void loop() {
break;

case 2:
cout << pstr("Test of println(double)\n");
cout << pstr("Test of println(uint32_t)\n");
break;
case 3:
cout << pstr("Test of printField(uint32_t, char)\n");
break;
case 4:
cout << pstr("Test of println(double)\n");
break;
}
file.truncate(0);
maxLatency = 0;
minLatency = 999999;
totalLatency = 0;
uint32_t t = millis();
for (uint16_t i = 0; i < N_PRINT; i++) {
uint32_t m = micros();
@@ -90,6 +99,14 @@ void loop() {
break;

case 2:
file.println(12345678UL + i);
break;
case 3:
file.printField(12345678UL + i, '\n');
break;
case 4:
file.println((double)0.01*i);
break;
}
@@ -102,7 +119,7 @@ void loop() {
if (minLatency > m) minLatency = m;
totalLatency += m;
}
file.sync();
file.close();
t = millis() - t;
double s = file.fileSize();
cout << pstr("Time ") << 0.001*t << pstr(" sec\n");
@@ -113,7 +130,6 @@ void loop() {
cout << pstr(" usec, Avg Latency: ");
cout << totalLatency/N_PRINT << pstr(" usec\n\n");
}
file.close();
cout << pstr("Done!\n\n");
}


+ 4
- 0
changes.txt Wyświetl plik

@@ -1,3 +1,7 @@
05 Sep 2014

Faster SdBaseFile::printField();

24 Aug 2014

Added support for Software SPI on Due and Teensy 3.1

Ładowanie…
Anuluj
Zapisz