Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By RichardS
#56776 Below you will find a code snippet that I wrote to test some odd SPIFFS behavior...

If the code is run all by itself in a sketch it will execute each section in around 7000mS each time....
Time first = 6928ms
Time second = 6929ms
Time third = 6927ms
Time fourth = 6928ms

BUT

When the same code is placed in my complicated sketch with all sorts of #include "x.h" and network code this same test function will take much much longer. And each iteration is even longer than the last.
Time first = 19629ms
Time second = 52770ms
Time third = 63290ms
Time fourth = 70745ms

So I placed the test code before everything else in setup() so its its first thing to run and in my large sketch its still slow....

So what is exectuing before setup()?????

RichardS

Code: Select all  #define SECTOR 256
  char buf[SECTOR];
  File fp;

  void make(String f, int n) {
    DEBUG("making %s length = %d\n", f.c_str(), n);

    SPIFFS.remove(f);
    File pESP = SPIFFS.open(f, "w");
    while (n > 0) {
      int bytes = (n > SECTOR) ? SECTOR : n;
      n -= SECTOR;
      memset(buf, n, sizeof(buf));
      fp.read((uint8_t*)buf, bytes);
      pESP.write((uint8_t*)buf, bytes);
      DEBUG("bytes = %d: n = %d\n", bytes, n);
      yield();
    }
    pESP.close();
  }
  void spiffsTest() {
    DEBUG("\nFormatting...\n");
    SPIFFS.format();

    make("/temp", 1234 + 12112 + 200220 + 454030 + 20220 + 100100);

    fp = SPIFFS.open("temp", "r");
    fp.seek(0, SeekEnd);
    fp.position();
    fp.seek(0, SeekSet);

    uint32_t startTime = millis();

    make("/1", 1234);
    make("/2", 12112);
    make("/3", 200220);
    make("/4", 454030);
    make("/5", 20220);
    make("/6", 100100);

    first = millis() - startTime;
    startTime = millis();

    make("/1", 1234);
    make("/2", 12112);
    make("/3", 200220);
    make("/4", 454030);
    make("/5", 20220);
    make("/6", 100100);

    second = millis() - startTime;
    startTime = millis();

    make("/1", 1234);
    make("/2", 12112);
    make("/3", 200220);
    make("/4", 454030);
    make("/5", 20220);
    make("/6", 100100);

    third = millis() - startTime;
    startTime = millis();

    make("/1", 1234);
    make("/2", 12112);
    make("/3", 200220);
    make("/4", 454030);
    make("/5", 20220);
    make("/6", 100100);

    DEBUG("Time first = %dms\n", first);
    DEBUG("Time second = %dms\n", second);
    DEBUG("Time third = %dms\n", third);
    DEBUG("Time fourth = %dms\n", millis() - startTime);
  }


also a list of all my includes:

Code: Select all#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include <Ticker.h>
#include <EEPROM.h>
#include <Arduino.h>
#include <WiFiUdp.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <WebSockets.h>
#include <WebSocketsServer.h>
#include <SPIFFSEditor.h>
#include <ESP8266mDNS.h>
#include <ArduinoJson.h>
#include <ArduinoOTA.h>
#include <ESP8266httpUpdate.h>
#include <FS.h>
#include <IPAddress.h>
#include <map>
User avatar
By danbicks
#56786 Richard,

Your killing this poor little ESP with all these library's lol. I could give you a few more I have created to see when it break's ......

Amazing little devices.

Dans
User avatar
By RichardS
#56798 Nope not broke, working very well at the moment.... other than the slow SPIFFS, I suspect it some type of interrupt issue as I think they turn them on and off during flash writes.... there is some interaction like that happening... (i think)

RichardS
User avatar
By RichardS
#56799 Got rid of some unneeded .h's see below //test commented out

Still slow.

RichardS

Code: Select all//test #include <WiFiClient.h>
//test #include <WiFiClientSecure.h>
//test #include <WiFiServer.h>
#include <WiFiUdp.h>
#include <Ticker.h>
//test #include <EEPROM.h>
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
//test #include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
//test #include <WebSockets.h>
#include <WebSocketsServer.h>
#include <SPIFFSEditor.h>
#include <ESP8266mDNS.h>
#include <ArduinoJson.h>
#include <ArduinoOTA.h>
#include <ESP8266httpUpdate.h>
#include <FS.h>
#include <IPAddress.h>
#include <map>