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

Moderator: igrr

User avatar
By eldonb46
#26827 martinayotte, and all,

OK, here is what I get, I have expanded the tests to include 3, 4, 5, and 6. The first two are your originals.

Test3 and Test4 uses a String Variables (which is the same length as your test)

Test5 and Test6 uses 30 short Strings in a loop, but the total transfer size is the same ( I think I have the size right ), also, they were modified to be consistent with functions I have previously tested, to show what I am seeing.

I have also added "FreeHeap" to the print, to make sure that was not a concern.

For my APPS, short html strings are typical used for Dynamic Web Pages ( although I do buffer them into a 1460 byte buffer before sending ).

If the functions "server.sendContent()" and "server.client().print()" share similar source code, I would think the time for Test5 and Test6 would be similar.

Note: My Web Page Server coding practices may be less than optimal, but I would not expect that much of a time difference, regardless of method used (assuming the coding is reasonable).

Thanks for your Assistance.

Eldon - WA0UWH



Code: Select allIP address: 192.168.2.162
MDNS responder started
HTTP server started
test1 duration = 71103, FreeHeap = 24408
test1 duration = 67384, FreeHeap = 24440
test1 duration = 22327, FreeHeap = 24440
test1 duration = 21619, FreeHeap = 24440

test2 duration = 7133, FreeHeap = 24504
test2 duration = 24740, FreeHeap = 24312
test2 duration = 16186, FreeHeap = 24120
test2 duration = 16348, FreeHeap = 23928

test3 duration = 60775, FreeHeap = 23672
test3 duration = 58506, FreeHeap = 23672
test3 duration = 306965, FreeHeap = 23544
test3 duration = 211195, FreeHeap = 23672

test4 duration = 20488, FreeHeap = 23736
test4 duration = 15849, FreeHeap = 21952
test4 duration = 16734, FreeHeap = 23352
test4 duration = 6687, FreeHeap = 23160

test5 duration = 63092283, FreeHeap = 24504
test5 duration = 63082917, FreeHeap = 24504
test5 duration = 63078014, FreeHeap = 24504
test5 duration = 63074285, FreeHeap = 24504

test6 duration = 99007, FreeHeap = 24312
test6 duration = 95931, FreeHeap = 24120
test6 duration = 63113, FreeHeap = 23928
test6 duration = 104843, FreeHeap = 23736


Here is the code that I am using in the HelloServer :

Code: Select all 
  server.on("/",  handleRoot );
  server.on("/1", handleTest1);
  server.on("/2", handleTest2);
  server.on("/3", handleTest3);
  server.on("/4", handleTest4);
  server.on("/5", handleTest5);
  server.on("/6", handleTest6);

-----------------------------------------------

String gTestStringShort = "\
hello TEST1 from esp8266!\r\n\
";

// 30 small Copies, total length is the same as in original test
String gTestString = "\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
hello TEST1 from esp8266!\r\n\
";


// Original Test
void handleTest1() {
  int prevTime = micros();
  server.send(200, "text/plain", "hello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\nhello TEST1 from esp8266!\r\n");
  int duration = micros() - prevTime;
  Serial.println(String("test1 duration = ") + duration + ", FreeHeap = " + ESP.getFreeHeap());
}

void handleTest2() {
  int prevTime = micros();
  server.client().print( "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n" );
  server.client().print("hello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\nhello TEST2 from esp8266!\r\n");
  int duration = micros() - prevTime;
  Serial.println(String("test2 duration = ") + duration + ", FreeHeap = " + ESP.getFreeHeap());
}


// Test using Strings
void handleTest3() {
  int prevTime = micros();
  server.send(200, "text/plain", gTestString);
  int duration = micros() - prevTime;
  Serial.println(String("test3 duration = ") + duration + ", FreeHeap = " + ESP.getFreeHeap());
}

void handleTest4() {
  int prevTime = micros();
  server.client().print( "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n" );
  server.client().print(gTestString);
  int duration = micros() - prevTime;
  Serial.println(String("test4 duration = ") + duration + ", FreeHeap = " + ESP.getFreeHeap());
}


// Test using Short Strings
void handleTest5() {
  int prevTime = micros();
  server.sendContent( "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n" );
  for(int i = 0; i < 30; i++) {
    server.sendContent(gTestStringShort);
  }
  int duration = micros() - prevTime;
  Serial.println(String("test5 duration = ") + duration + ", FreeHeap = " + ESP.getFreeHeap());
}

void handleTest6() {
  int prevTime = micros();
  server.client().print( "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n" );
  for(int i = 0; i < 30; i++) {
    server.client().print(gTestStringShort);
  }
  int duration = micros() - prevTime;
  Serial.println(String("test6 duration = ") + duration + ", FreeHeap = " + ESP.getFreeHeap());
}


---
User avatar
By eldonb46
#26828 [quote="martinayotte"]Nope, still the same ...

Code: Select alltest1 duration = 4982
test2 duration = 3124
test1 duration = 3713
test2 duration = 3929
test1 duration = 4057
test2 duration = 3962


Interesting, your times for Test1 and Test2 are about 10 times faster than mine. I need to explore this.

Eldon - WA0UWH

--