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
#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:
#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>
https://epartsconnect.com
Live realtime stock market prediction website. https://www.stocksignalslive.com my latest creation. Uses AI and machine learning.
New site featuring ESP8266 and ESP32 projects. tutorials, and news.
http://EverythingESP.com
ESP8266.com Founder and Administrator
The Mind Factory (get more from your 3D printer)
Home of the ESP8266, ESP8285, and ESP32 microcontrollers....