Skip to content

SPIFFS into esp32 flashram: Reading is 8 times slower than writing a file ? #1597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
euquiq opened this issue Jul 4, 2018 · 1 comment
Closed

Comments

@euquiq
Copy link

euquiq commented Jul 4, 2018

I am using latest ESP32 Arduino framework.

I always thought reading a file should be really faster than writing. But I already tested it in several ESP32 boards I got in here and I am getting just the opposite result.

This is the code I am using:

#include "FS.h"
#include "SPIFFS.h"

void setup()
{
	Serial.begin(115200);
	delay(1000);
	ulong ini, fin = 0;
	if (!SPIFFS.begin(true)) {
		Serial.println("SPIFFS Mount Failed");
	}
	else
	{
		//
		// FORMAT
		//
		Serial.print("FORMAT: ");
		ini = millis();
		SPIFFS.format();
		fin = millis();
		fin = fin - ini;
		Serial.println((String)fin + " millis");
		String filename = "/test";
		//
		// CREATE FILE AND PUT SOME TEXT
		//
		Serial.print("CREATE / WRITE: ");
		ini = millis();
		File file = SPIFFS.open(filename, FILE_WRITE);
		file.println("EXAMPLE TEXT CONTENT");
		file.flush();
		file.close();
		fin = millis();
		fin = fin - ini;
		Serial.println((String)fin + " millis");
		//
		// READ FILE
		//
		Serial.print("READ: ");
		String result = "";
		ini = millis();
		File file2 = SPIFFS.open(filename);
		result = file2.readString();
		fin = millis();
		fin = fin - ini;
		Serial.println((String)fin + " millis / result: " + result);
	}
}

void loop()
{
	delay(5000);
}

This is the Output I am getting:

FORMAT: 14508 millis
CREATE / WRITE: 156 millis
READ: 1001 millis / result: EXAMPLE TEXT CONTENT

I am assuming I am doing something (VERY) wrong, but just in case, I am anyway raising an issue!

Regards,

Enrique

@me-no-dev
Copy link
Member

Fixed :) readString was waiting for timeout (Stream function)

Curclamas pushed a commit to Curclamas/arduino-esp32 that referenced this issue Aug 21, 2018
blue-2357 pushed a commit to blue-2357/arduino-esp32 that referenced this issue Jul 17, 2024
dash0820 added a commit to dash0820/arduino-esp32-stripped that referenced this issue Mar 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants