Switch HTTP Server
This commit is contained in:
6
lib/PsychicHttp/benchmark/arduinomongoose/.gitignore
vendored
Normal file
6
lib/PsychicHttp/benchmark/arduinomongoose/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.pio
|
||||
.vscode/
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
BIN
lib/PsychicHttp/benchmark/arduinomongoose/data/www/alien.png
Normal file
BIN
lib/PsychicHttp/benchmark/arduinomongoose/data/www/alien.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
39
lib/PsychicHttp/benchmark/arduinomongoose/include/README
Normal file
39
lib/PsychicHttp/benchmark/arduinomongoose/include/README
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
46
lib/PsychicHttp/benchmark/arduinomongoose/lib/README
Normal file
46
lib/PsychicHttp/benchmark/arduinomongoose/lib/README
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
22
lib/PsychicHttp/benchmark/arduinomongoose/platformio.ini
Normal file
22
lib/PsychicHttp/benchmark/arduinomongoose/platformio.ini
Normal file
@@ -0,0 +1,22 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
lib_deps =
|
||||
jeremypoulter/ArduinoMongoose
|
||||
bblanchon/ArduinoJson
|
||||
board_build.filesystem = littlefs
|
||||
|
||||
[env:default]
|
||||
234
lib/PsychicHttp/benchmark/arduinomongoose/src/main.cpp
Normal file
234
lib/PsychicHttp/benchmark/arduinomongoose/src/main.cpp
Normal file
@@ -0,0 +1,234 @@
|
||||
/* Wi-Fi STA Connect and Disconnect Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <MongooseCore.h>
|
||||
#include <MongooseHttpServer.h>
|
||||
#include <LittleFS.h>
|
||||
#include <ArduinoJSON.h>
|
||||
|
||||
const char *ssid = "";
|
||||
const char *password = "";
|
||||
|
||||
MongooseHttpServer server;
|
||||
|
||||
const char *htmlContent = R"(
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Sample HTML</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, World!</h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
</body>
|
||||
</html>
|
||||
)";
|
||||
|
||||
bool connectToWifi()
|
||||
{
|
||||
Serial.println();
|
||||
Serial.print("[WiFi] Connecting to ");
|
||||
Serial.println(ssid);
|
||||
|
||||
WiFi.setSleep(false);
|
||||
WiFi.useStaticBuffers(true);
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
// Will try for about 10 seconds (20x 500ms)
|
||||
int tryDelay = 500;
|
||||
int numberOfTries = 20;
|
||||
|
||||
// Wait for the WiFi event
|
||||
while (true)
|
||||
{
|
||||
switch (WiFi.status())
|
||||
{
|
||||
case WL_NO_SSID_AVAIL:
|
||||
Serial.println("[WiFi] SSID not found");
|
||||
break;
|
||||
case WL_CONNECT_FAILED:
|
||||
Serial.print("[WiFi] Failed - WiFi not connected! Reason: ");
|
||||
return false;
|
||||
break;
|
||||
case WL_CONNECTION_LOST:
|
||||
Serial.println("[WiFi] Connection was lost");
|
||||
break;
|
||||
case WL_SCAN_COMPLETED:
|
||||
Serial.println("[WiFi] Scan is completed");
|
||||
break;
|
||||
case WL_DISCONNECTED:
|
||||
Serial.println("[WiFi] WiFi is disconnected");
|
||||
break;
|
||||
case WL_CONNECTED:
|
||||
Serial.println("[WiFi] WiFi is connected!");
|
||||
Serial.print("[WiFi] IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
Serial.print("[WiFi] WiFi Status: ");
|
||||
Serial.println(WiFi.status());
|
||||
break;
|
||||
}
|
||||
delay(tryDelay);
|
||||
|
||||
if (numberOfTries <= 0)
|
||||
{
|
||||
Serial.print("[WiFi] Failed to connect to WiFi!");
|
||||
// Use disconnect function to force stop trying to connect
|
||||
WiFi.disconnect();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
numberOfTries--;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(10);
|
||||
Serial.println("ArduinoMongoose Benchmark");
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
// To debug, please enable Core Debug Level to Verbose
|
||||
if (connectToWifi())
|
||||
{
|
||||
if(!LittleFS.begin())
|
||||
{
|
||||
Serial.println("LittleFS Mount Failed. Do Platform -> Build Filesystem Image and Platform -> Upload Filesystem Image from VSCode");
|
||||
return;
|
||||
}
|
||||
|
||||
//start our server
|
||||
Mongoose.begin();
|
||||
server.begin(80);
|
||||
|
||||
//index file
|
||||
server.on("/", HTTP_GET, [](MongooseHttpServerRequest *request)
|
||||
{
|
||||
request->send(200, "text/html", htmlContent);
|
||||
});
|
||||
|
||||
//api - parameters passed in via query eg. /api/endpoint?foo=bar
|
||||
server.on("/api", HTTP_GET, [](MongooseHttpServerRequest *request)
|
||||
{
|
||||
//create a response object
|
||||
StaticJsonDocument<128> output;
|
||||
output["msg"] = "status";
|
||||
output["status"] = "success";
|
||||
output["millis"] = millis();
|
||||
|
||||
//work with some params
|
||||
if (request->hasParam("foo"))
|
||||
{
|
||||
String foo = request->getParam("foo");
|
||||
output["foo"] = foo;
|
||||
}
|
||||
|
||||
//serialize and return
|
||||
String jsonBuffer;
|
||||
serializeJson(output, jsonBuffer);
|
||||
request->send(200, "application/json", jsonBuffer.c_str());
|
||||
});
|
||||
|
||||
//websocket
|
||||
server.on("/ws$")->
|
||||
onFrame([](MongooseHttpWebSocketConnection *connection, int flags, uint8_t *data, size_t len) {
|
||||
connection->send(WEBSOCKET_OP_TEXT, data, len);
|
||||
//server.sendAll(connection, (char *)data);
|
||||
});
|
||||
|
||||
//hack - no servestatic
|
||||
server.on("/alien.png", HTTP_GET, [](MongooseHttpServerRequest *request)
|
||||
{
|
||||
//open our file
|
||||
File fp = LittleFS.open("/www/alien.png");
|
||||
size_t length = fp.size();
|
||||
|
||||
//read our data
|
||||
uint8_t * data = (uint8_t *)malloc(length);
|
||||
if (data != NULL)
|
||||
{
|
||||
fp.readBytes((char *)data, length);
|
||||
|
||||
//send it off
|
||||
MongooseHttpServerResponseBasic *response = request->beginResponse();
|
||||
response->setContent(data, length);
|
||||
response->setContentType("image/png");
|
||||
response->setCode(200);
|
||||
request->send(response);
|
||||
|
||||
//free the memory
|
||||
free(data);
|
||||
}
|
||||
else
|
||||
request->send(503);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
Mongoose.poll(1000);
|
||||
}
|
||||
11
lib/PsychicHttp/benchmark/arduinomongoose/test/README
Normal file
11
lib/PsychicHttp/benchmark/arduinomongoose/test/README
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||
BIN
lib/PsychicHttp/benchmark/comparison.ods
Normal file
BIN
lib/PsychicHttp/benchmark/comparison.ods
Normal file
Binary file not shown.
6
lib/PsychicHttp/benchmark/espasyncwebserver/.gitignore
vendored
Normal file
6
lib/PsychicHttp/benchmark/espasyncwebserver/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.pio
|
||||
.vscode/
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
BIN
lib/PsychicHttp/benchmark/espasyncwebserver/data/www/alien.png
Normal file
BIN
lib/PsychicHttp/benchmark/espasyncwebserver/data/www/alien.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
39
lib/PsychicHttp/benchmark/espasyncwebserver/include/README
Normal file
39
lib/PsychicHttp/benchmark/espasyncwebserver/include/README
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
46
lib/PsychicHttp/benchmark/espasyncwebserver/lib/README
Normal file
46
lib/PsychicHttp/benchmark/espasyncwebserver/lib/README
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
22
lib/PsychicHttp/benchmark/espasyncwebserver/platformio.ini
Normal file
22
lib/PsychicHttp/benchmark/espasyncwebserver/platformio.ini
Normal file
@@ -0,0 +1,22 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
lib_deps =
|
||||
https://github.com/me-no-dev/ESPAsyncWebServer
|
||||
bblanchon/ArduinoJson
|
||||
board_build.filesystem = littlefs
|
||||
|
||||
[env:default]
|
||||
276
lib/PsychicHttp/benchmark/espasyncwebserver/src/main.cpp
Normal file
276
lib/PsychicHttp/benchmark/espasyncwebserver/src/main.cpp
Normal file
@@ -0,0 +1,276 @@
|
||||
/* Wi-Fi STA Connect and Disconnect Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <LittleFS.h>
|
||||
#include <ArduinoJSON.h>
|
||||
|
||||
const char *ssid = "";
|
||||
const char *password = "";
|
||||
|
||||
AsyncWebServer server(80);
|
||||
AsyncWebSocket ws("/ws");
|
||||
|
||||
const char *htmlContent = R"(
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Sample HTML</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, World!</h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
</body>
|
||||
</html>
|
||||
)";
|
||||
|
||||
bool connectToWifi()
|
||||
{
|
||||
Serial.println();
|
||||
Serial.print("[WiFi] Connecting to ");
|
||||
Serial.println(ssid);
|
||||
|
||||
WiFi.setSleep(false);
|
||||
WiFi.useStaticBuffers(true);
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
// Will try for about 10 seconds (20x 500ms)
|
||||
int tryDelay = 500;
|
||||
int numberOfTries = 20;
|
||||
|
||||
// Wait for the WiFi event
|
||||
while (true)
|
||||
{
|
||||
switch (WiFi.status())
|
||||
{
|
||||
case WL_NO_SSID_AVAIL:
|
||||
Serial.println("[WiFi] SSID not found");
|
||||
break;
|
||||
case WL_CONNECT_FAILED:
|
||||
Serial.print("[WiFi] Failed - WiFi not connected! Reason: ");
|
||||
return false;
|
||||
break;
|
||||
case WL_CONNECTION_LOST:
|
||||
Serial.println("[WiFi] Connection was lost");
|
||||
break;
|
||||
case WL_SCAN_COMPLETED:
|
||||
Serial.println("[WiFi] Scan is completed");
|
||||
break;
|
||||
case WL_DISCONNECTED:
|
||||
Serial.println("[WiFi] WiFi is disconnected");
|
||||
break;
|
||||
case WL_CONNECTED:
|
||||
Serial.println("[WiFi] WiFi is connected!");
|
||||
Serial.print("[WiFi] IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
Serial.print("[WiFi] WiFi Status: ");
|
||||
Serial.println(WiFi.status());
|
||||
break;
|
||||
}
|
||||
delay(tryDelay);
|
||||
|
||||
if (numberOfTries <= 0)
|
||||
{
|
||||
Serial.print("[WiFi] Failed to connect to WiFi!");
|
||||
// Use disconnect function to force stop trying to connect
|
||||
WiFi.disconnect();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
numberOfTries--;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void onEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){
|
||||
if(type == WS_EVT_CONNECT){
|
||||
//client connected
|
||||
// Serial.printf("ws[%s][%u] connect\n", server->url(), client->id());
|
||||
// client->printf("Hello Client %u :)", client->id());
|
||||
// client->ping();
|
||||
} else if(type == WS_EVT_DISCONNECT){
|
||||
//client disconnected
|
||||
// Serial.printf("ws[%s][%u] disconnect: %u\n", server->url(), client->id());
|
||||
} else if(type == WS_EVT_ERROR){
|
||||
//error was received from the other end
|
||||
// Serial.printf("ws[%s][%u] error(%u): %s\n", server->url(), client->id(), *((uint16_t*)arg), (char*)data);
|
||||
} else if(type == WS_EVT_PONG){
|
||||
//pong message was received (in response to a ping request maybe)
|
||||
// Serial.printf("ws[%s][%u] pong[%u]: %s\n", server->url(), client->id(), len, (len)?(char*)data:"");
|
||||
} else if(type == WS_EVT_DATA){
|
||||
//data packet
|
||||
AwsFrameInfo * info = (AwsFrameInfo*)arg;
|
||||
if(info->final && info->index == 0 && info->len == len){
|
||||
//the whole message is in a single frame and we got all of it's data
|
||||
// Serial.printf("ws[%s][%u] %s-message[%llu]: ", server->url(), client->id(), (info->opcode == WS_TEXT)?"text":"binary", info->len);
|
||||
if(info->opcode == WS_TEXT){
|
||||
data[len] = 0;
|
||||
// Serial.printf("%s\n", (char*)data);
|
||||
} else {
|
||||
// for(size_t i=0; i < info->len; i++){
|
||||
// Serial.printf("%02x ", data[i]);
|
||||
// }
|
||||
// Serial.printf("\n");
|
||||
}
|
||||
if(info->opcode == WS_TEXT)
|
||||
{
|
||||
client->text((char *)data, len);
|
||||
}
|
||||
// else
|
||||
// client->binary("I got your binary message");
|
||||
} else {
|
||||
//message is comprised of multiple frames or the frame is split into multiple packets
|
||||
if(info->index == 0){
|
||||
// if(info->num == 0)
|
||||
// Serial.printf("ws[%s][%u] %s-message start\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
|
||||
// Serial.printf("ws[%s][%u] frame[%u] start[%llu]\n", server->url(), client->id(), info->num, info->len);
|
||||
}
|
||||
|
||||
Serial.printf("ws[%s][%u] frame[%u] %s[%llu - %llu]: ", server->url(), client->id(), info->num, (info->message_opcode == WS_TEXT)?"text":"binary", info->index, info->index + len);
|
||||
if(info->message_opcode == WS_TEXT){
|
||||
data[len] = 0;
|
||||
// Serial.printf("%s\n", (char*)data);
|
||||
} else {
|
||||
// for(size_t i=0; i < len; i++){
|
||||
// Serial.printf("%02x ", data[i]);
|
||||
// }
|
||||
// Serial.printf("\n");
|
||||
}
|
||||
|
||||
if((info->index + len) == info->len){
|
||||
// Serial.printf("ws[%s][%u] frame[%u] end[%llu]\n", server->url(), client->id(), info->num, info->len);
|
||||
if(info->final){
|
||||
// Serial.printf("ws[%s][%u] %s-message end\n", server->url(), client->id(), (info->message_opcode == WS_TEXT)?"text":"binary");
|
||||
if(info->message_opcode == WS_TEXT)
|
||||
{
|
||||
client->text((char *)data, info->len);
|
||||
}
|
||||
// else
|
||||
// client->binary("I got your binary message");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(10);
|
||||
Serial.println("ESPAsyncWebserver Benchmark");
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
// To debug, please enable Core Debug Level to Verbose
|
||||
if (connectToWifi())
|
||||
{
|
||||
if(!LittleFS.begin())
|
||||
{
|
||||
Serial.println("LittleFS Mount Failed. Do Platform -> Build Filesystem Image and Platform -> Upload Filesystem Image from VSCode");
|
||||
return;
|
||||
}
|
||||
|
||||
//api - parameters passed in via query eg. /api/endpoint?foo=bar
|
||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
request->send(200, "text/html", htmlContent);
|
||||
});
|
||||
|
||||
//serve static files from LittleFS/www on /
|
||||
server.serveStatic("/", LittleFS, "/www/");
|
||||
|
||||
//api - parameters passed in via query eg. /api/endpoint?foo=bar
|
||||
server.on("/api", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||
{
|
||||
//create a response object
|
||||
StaticJsonDocument<128> output;
|
||||
output["msg"] = "status";
|
||||
output["status"] = "success";
|
||||
output["millis"] = millis();
|
||||
|
||||
//work with some params
|
||||
if (request->hasParam("foo"))
|
||||
{
|
||||
AsyncWebParameter* foo = request->getParam("foo");
|
||||
output["foo"] = foo->value();
|
||||
}
|
||||
|
||||
//serialize and return
|
||||
String jsonBuffer;
|
||||
serializeJson(output, jsonBuffer);
|
||||
request->send(200, "application/json", jsonBuffer.c_str());
|
||||
});
|
||||
|
||||
ws.onEvent(onEvent);
|
||||
server.addHandler(&ws);
|
||||
|
||||
server.begin();
|
||||
}
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
ws.cleanupClients();
|
||||
delay(1000);
|
||||
}
|
||||
11
lib/PsychicHttp/benchmark/espasyncwebserver/test/README
Normal file
11
lib/PsychicHttp/benchmark/espasyncwebserver/test/README
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||
39
lib/PsychicHttp/benchmark/eventsource-client-test.js
Normal file
39
lib/PsychicHttp/benchmark/eventsource-client-test.js
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const EventSource = require('eventsource');
|
||||
const url = 'http://192.168.2.131/events';
|
||||
|
||||
async function eventSourceClient() {
|
||||
console.log(`Starting test`);
|
||||
for (let i = 0; i < 1000000; i++)
|
||||
{
|
||||
if (i % 100 == 0)
|
||||
console.log(`Count: ${i}`);
|
||||
|
||||
let eventSource = new EventSource(url);
|
||||
|
||||
eventSource.onopen = () => {
|
||||
//console.log('EventSource connection opened.');
|
||||
};
|
||||
|
||||
eventSource.onerror = (error) => {
|
||||
console.error('EventSource error:', error);
|
||||
|
||||
// Close the connection on error
|
||||
eventSource.close();
|
||||
};
|
||||
|
||||
await new Promise((resolve) => {
|
||||
eventSource.onmessage = (event) => {
|
||||
//console.log('Received message:', event.data);
|
||||
|
||||
// Close the connection after receiving the first message
|
||||
eventSource.close();
|
||||
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
eventSourceClient();
|
||||
43
lib/PsychicHttp/benchmark/http-client-test.js
Normal file
43
lib/PsychicHttp/benchmark/http-client-test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const axios = require('axios');
|
||||
|
||||
const url = 'http://192.168.2.131/api';
|
||||
const queryParams = {
|
||||
foo: 'bar',
|
||||
foo1: 'bar',
|
||||
foo2: 'bar',
|
||||
foo3: 'bar',
|
||||
foo4: 'bar',
|
||||
foo5: 'bar',
|
||||
foo6: 'bar',
|
||||
};
|
||||
|
||||
const totalRequests = 1000000;
|
||||
const requestsPerCount = 100;
|
||||
|
||||
let requestCount = 0;
|
||||
|
||||
function fetchData() {
|
||||
axios.get(url, { params: queryParams })
|
||||
.then(response => {
|
||||
requestCount++;
|
||||
|
||||
if (requestCount % requestsPerCount === 0) {
|
||||
console.log(`Requests completed: ${requestCount}`);
|
||||
}
|
||||
|
||||
if (requestCount < totalRequests) {
|
||||
fetchData();
|
||||
} else {
|
||||
console.log('All requests completed.');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error making request:', error.message);
|
||||
});
|
||||
}
|
||||
|
||||
// Start making requests
|
||||
console.log(`Starting test`);
|
||||
fetchData();
|
||||
BIN
lib/PsychicHttp/benchmark/latency.png
Normal file
BIN
lib/PsychicHttp/benchmark/latency.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 49 KiB |
37
lib/PsychicHttp/benchmark/loadtest-http.sh
Normal file
37
lib/PsychicHttp/benchmark/loadtest-http.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
#Command to install the testers:
|
||||
# npm install -g autocannon
|
||||
|
||||
TEST_IP="192.168.2.131"
|
||||
TEST_TIME=60
|
||||
LOG_FILE=psychic-http-loadtest.log
|
||||
TIMEOUT=10000
|
||||
PROTOCOL=http
|
||||
#PROTOCOL=https
|
||||
|
||||
if test -f "$LOG_FILE"; then
|
||||
rm $LOG_FILE
|
||||
fi
|
||||
|
||||
for CONCURRENCY in 1 2 3 4 5 6 7 8 9 10 15 20
|
||||
#for CONCURRENCY in 20
|
||||
do
|
||||
printf "\n\nCLIENTS: *** $CONCURRENCY ***\n\n" >> $LOG_FILE
|
||||
echo "Testing $CONCURRENCY clients on $PROTOCOL://$TEST_IP/"
|
||||
#loadtest -c $CONCURRENCY --cores 1 -t $TEST_TIME --timeout $TIMEOUT "$PROTOCOL://$TEST_IP/" --quiet >> $LOG_FILE
|
||||
autocannon -c $CONCURRENCY -w 1 -d $TEST_TIME --renderStatusCodes "$PROTOCOL://$TEST_IP/" >> $LOG_FILE 2>&1
|
||||
printf "\n\n----------------\n\n" >> $LOG_FILE
|
||||
sleep 1
|
||||
|
||||
echo "Testing $CONCURRENCY clients on $PROTOCOL://$TEST_IP/api"
|
||||
#loadtest -c $CONCURRENCY --cores 1 -t $TEST_TIME --timeout $TIMEOUT "$PROTOCOL://$TEST_IP/api?foo=bar" --quiet >> $LOG_FILE
|
||||
autocannon -c $CONCURRENCY -w 1 -d $TEST_TIME --renderStatusCodes "$PROTOCOL://$TEST_IP/api?foo=bar" >> $LOG_FILE 2>&1
|
||||
printf "\n\n----------------\n\n" >> $LOG_FILE
|
||||
sleep 1
|
||||
|
||||
echo "Testing $CONCURRENCY clients on $PROTOCOL://$TEST_IP/alien.png"
|
||||
#loadtest -c $CONCURRENCY --cores 1 -t $TEST_TIME --timeout $TIMEOUT "$PROTOCOL://$TEST_IP/alien.png" --quiet >> $LOG_FILE
|
||||
autocannon -c $CONCURRENCY -w 1 -d $TEST_TIME --renderStatusCodes "$PROTOCOL://$TEST_IP/alien.png" >> $LOG_FILE 2>&1
|
||||
printf "\n\n----------------\n\n" >> $LOG_FILE
|
||||
sleep 1
|
||||
done
|
||||
31
lib/PsychicHttp/benchmark/loadtest-websocket.sh
Normal file
31
lib/PsychicHttp/benchmark/loadtest-websocket.sh
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
#Command to install the testers:
|
||||
# npm install -g loadtest
|
||||
|
||||
TEST_IP="192.168.2.131"
|
||||
TEST_TIME=60
|
||||
LOG_FILE=psychic-websocket-loadtest.log
|
||||
PROTOCOL=ws
|
||||
#PROTOCOL=wss
|
||||
|
||||
if test -f "$LOG_FILE"; then
|
||||
rm $LOG_FILE
|
||||
fi
|
||||
|
||||
for CONCURRENCY in 1 2 3 4 5 6 7
|
||||
do
|
||||
printf "\n\nCLIENTS: *** $CONCURRENCY ***\n\n" >> $LOG_FILE
|
||||
echo "Testing $CONCURRENCY clients on $PROTOCOL://$TEST_IP/ws"
|
||||
loadtest -c $CONCURRENCY --cores 1 -t $TEST_TIME --insecure $PROTOCOL://$TEST_IP/ws --quiet 2> /dev/null >> $LOG_FILE
|
||||
sleep 1
|
||||
done
|
||||
|
||||
for CONNECTIONS in 8 10 16 20
|
||||
#for CONNECTIONS in 20
|
||||
do
|
||||
CONCURRENCY=$((CONNECTIONS / 2))
|
||||
printf "\n\nCLIENTS: *** $CONNECTIONS ***\n\n" >> $LOG_FILE
|
||||
echo "Testing $CONNECTIONS clients on $PROTOCOL://$TEST_IP/ws"
|
||||
loadtest -c $CONCURRENCY --cores 2 -t $TEST_TIME --insecure $PROTOCOL://$TEST_IP/ws --quiet 2> /dev/null >> $LOG_FILE
|
||||
sleep 1
|
||||
done
|
||||
7
lib/PsychicHttp/benchmark/package.json
Normal file
7
lib/PsychicHttp/benchmark/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"axios": "^1.6.2",
|
||||
"eventsource": "^2.0.2",
|
||||
"ws": "^8.14.2"
|
||||
}
|
||||
}
|
||||
BIN
lib/PsychicHttp/benchmark/performance.png
Normal file
BIN
lib/PsychicHttp/benchmark/performance.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
6
lib/PsychicHttp/benchmark/psychichttp/.gitignore
vendored
Normal file
6
lib/PsychicHttp/benchmark/psychichttp/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.pio
|
||||
.vscode/
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
BIN
lib/PsychicHttp/benchmark/psychichttp/data/www/alien.png
Normal file
BIN
lib/PsychicHttp/benchmark/psychichttp/data/www/alien.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
39
lib/PsychicHttp/benchmark/psychichttp/include/README
Normal file
39
lib/PsychicHttp/benchmark/psychichttp/include/README
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
46
lib/PsychicHttp/benchmark/psychichttp/lib/README
Normal file
46
lib/PsychicHttp/benchmark/psychichttp/lib/README
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
22
lib/PsychicHttp/benchmark/psychichttp/platformio.ini
Normal file
22
lib/PsychicHttp/benchmark/psychichttp/platformio.ini
Normal file
@@ -0,0 +1,22 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
lib_deps =
|
||||
https://github.com/hoeken/PsychicHttp
|
||||
bblanchon/ArduinoJson
|
||||
board_build.filesystem = littlefs
|
||||
|
||||
[env:default]
|
||||
228
lib/PsychicHttp/benchmark/psychichttp/src/main.cpp
Normal file
228
lib/PsychicHttp/benchmark/psychichttp/src/main.cpp
Normal file
@@ -0,0 +1,228 @@
|
||||
/* Wi-Fi STA Connect and Disconnect Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <PsychicHttp.h>
|
||||
#include <LittleFS.h>
|
||||
#include <ArduinoJSON.h>
|
||||
#include "_secret.h"
|
||||
|
||||
#ifndef WIFI_SSID
|
||||
#error "You need to enter your wifi credentials. Copy secret.h to _secret.h and enter your credentials there."
|
||||
#endif
|
||||
|
||||
//Enter your WIFI credentials in secret.h
|
||||
const char *ssid = WIFI_SSID;
|
||||
const char *password = WIFI_PASS;
|
||||
|
||||
PsychicHttpServer server;
|
||||
PsychicWebSocketHandler websocketHandler;
|
||||
PsychicEventSource eventSource;
|
||||
|
||||
const char *htmlContent = R"(
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Sample HTML</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, World!</h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
</body>
|
||||
</html>
|
||||
)";
|
||||
|
||||
bool connectToWifi()
|
||||
{
|
||||
Serial.println();
|
||||
Serial.print("[WiFi] Connecting to ");
|
||||
Serial.println(ssid);
|
||||
|
||||
WiFi.setSleep(false);
|
||||
WiFi.useStaticBuffers(true);
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
// Will try for about 10 seconds (20x 500ms)
|
||||
int tryDelay = 500;
|
||||
int numberOfTries = 20;
|
||||
|
||||
// Wait for the WiFi event
|
||||
while (true)
|
||||
{
|
||||
switch (WiFi.status())
|
||||
{
|
||||
case WL_NO_SSID_AVAIL:
|
||||
Serial.println("[WiFi] SSID not found");
|
||||
break;
|
||||
case WL_CONNECT_FAILED:
|
||||
Serial.print("[WiFi] Failed - WiFi not connected! Reason: ");
|
||||
return false;
|
||||
break;
|
||||
case WL_CONNECTION_LOST:
|
||||
Serial.println("[WiFi] Connection was lost");
|
||||
break;
|
||||
case WL_SCAN_COMPLETED:
|
||||
Serial.println("[WiFi] Scan is completed");
|
||||
break;
|
||||
case WL_DISCONNECTED:
|
||||
Serial.println("[WiFi] WiFi is disconnected");
|
||||
break;
|
||||
case WL_CONNECTED:
|
||||
Serial.println("[WiFi] WiFi is connected!");
|
||||
Serial.print("[WiFi] IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
Serial.print("[WiFi] WiFi Status: ");
|
||||
Serial.println(WiFi.status());
|
||||
break;
|
||||
}
|
||||
delay(tryDelay);
|
||||
|
||||
if (numberOfTries <= 0)
|
||||
{
|
||||
Serial.print("[WiFi] Failed to connect to WiFi!");
|
||||
// Use disconnect function to force stop trying to connect
|
||||
WiFi.disconnect();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
numberOfTries--;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(10);
|
||||
Serial.println("PsychicHTTP Benchmark");
|
||||
|
||||
if (connectToWifi())
|
||||
{
|
||||
if(!LittleFS.begin())
|
||||
{
|
||||
Serial.println("LittleFS Mount Failed. Do Platform -> Build Filesystem Image and Platform -> Upload Filesystem Image from VSCode");
|
||||
return;
|
||||
}
|
||||
|
||||
//start our server
|
||||
server.listen(80);
|
||||
|
||||
//our index
|
||||
server.on("/", HTTP_GET, [](PsychicRequest *request)
|
||||
{
|
||||
return request->reply(200, "text/html", htmlContent);
|
||||
});
|
||||
|
||||
//serve static files from LittleFS/www on /
|
||||
server.serveStatic("/", LittleFS, "/www/");
|
||||
|
||||
//a websocket echo server
|
||||
websocketHandler.onOpen([](PsychicWebSocketClient *client) {
|
||||
client->sendMessage("Hello!");
|
||||
});
|
||||
websocketHandler.onFrame([](PsychicWebSocketRequest *request, httpd_ws_frame *frame) {
|
||||
request->reply(frame);
|
||||
return ESP_OK;
|
||||
});
|
||||
server.on("/ws", &websocketHandler);
|
||||
|
||||
//EventSource server
|
||||
eventSource.onOpen([](PsychicEventSourceClient *client) {
|
||||
client->send("Hello", NULL, millis(), 1000);
|
||||
});
|
||||
server.on("/events", &eventSource);
|
||||
|
||||
//api - parameters passed in via query eg. /api/endpoint?foo=bar
|
||||
server.on("/api", HTTP_GET, [](PsychicRequest *request)
|
||||
{
|
||||
//create a response object
|
||||
StaticJsonDocument<128> output;
|
||||
output["msg"] = "status";
|
||||
output["status"] = "success";
|
||||
output["millis"] = millis();
|
||||
|
||||
//work with some params
|
||||
if (request->hasParam("foo"))
|
||||
{
|
||||
String foo = request->getParam("foo")->value();
|
||||
output["foo"] = foo;
|
||||
}
|
||||
|
||||
//serialize and return
|
||||
String jsonBuffer;
|
||||
serializeJson(output, jsonBuffer);
|
||||
return request->reply(200, "application/json", jsonBuffer.c_str());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long last;
|
||||
void loop()
|
||||
{
|
||||
if (millis() - last > 1000)
|
||||
{
|
||||
Serial.printf("Free Heap: %d\n", esp_get_free_heap_size());
|
||||
last = millis();
|
||||
}
|
||||
}
|
||||
2
lib/PsychicHttp/benchmark/psychichttp/src/secret.h
Normal file
2
lib/PsychicHttp/benchmark/psychichttp/src/secret.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#define WIFI_SSID "Your_SSID"
|
||||
#define WIFI_PASS "Your_PASS"
|
||||
11
lib/PsychicHttp/benchmark/psychichttp/test/README
Normal file
11
lib/PsychicHttp/benchmark/psychichttp/test/README
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||
6
lib/PsychicHttp/benchmark/psychichttps/.gitignore
vendored
Normal file
6
lib/PsychicHttp/benchmark/psychichttps/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.pio
|
||||
.vscode/
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
19
lib/PsychicHttp/benchmark/psychichttps/data/server.crt
Normal file
19
lib/PsychicHttp/benchmark/psychichttps/data/server.crt
Normal file
@@ -0,0 +1,19 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDKzCCAhOgAwIBAgIUBxM3WJf2bP12kAfqhmhhjZWv0ukwDQYJKoZIhvcNAQEL
|
||||
BQAwJTEjMCEGA1UEAwwaRVNQMzIgSFRUUFMgc2VydmVyIGV4YW1wbGUwHhcNMTgx
|
||||
MDE3MTEzMjU3WhcNMjgxMDE0MTEzMjU3WjAlMSMwIQYDVQQDDBpFU1AzMiBIVFRQ
|
||||
UyBzZXJ2ZXIgZXhhbXBsZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
|
||||
ALBint6nP77RCQcmKgwPtTsGK0uClxg+LwKJ3WXuye3oqnnjqJCwMEneXzGdG09T
|
||||
sA0SyNPwrEgebLCH80an3gWU4pHDdqGHfJQa2jBL290e/5L5MB+6PTs2NKcojK/k
|
||||
qcZkn58MWXhDW1NpAnJtjVniK2Ksvr/YIYSbyD+JiEs0MGxEx+kOl9d7hRHJaIzd
|
||||
GF/vO2pl295v1qXekAlkgNMtYIVAjUy9CMpqaQBCQRL+BmPSJRkXBsYk8GPnieS4
|
||||
sUsp53DsNvCCtWDT6fd9D1v+BB6nDk/FCPKhtjYOwOAZlX4wWNSZpRNr5dfrxKsb
|
||||
jAn4PCuR2akdF4G8WLUeDWECAwEAAaNTMFEwHQYDVR0OBBYEFMnmdJKOEepXrHI/
|
||||
ivM6mVqJgAX8MB8GA1UdIwQYMBaAFMnmdJKOEepXrHI/ivM6mVqJgAX8MA8GA1Ud
|
||||
EwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBADiXIGEkSsN0SLSfCF1VNWO3
|
||||
emBurfOcDq4EGEaxRKAU0814VEmU87btIDx80+z5Dbf+GGHCPrY7odIkxGNn0DJY
|
||||
W1WcF+DOcbiWoUN6DTkAML0SMnp8aGj9ffx3x+qoggT+vGdWVVA4pgwqZT7Ybntx
|
||||
bkzcNFW0sqmCv4IN1t4w6L0A87ZwsNwVpre/j6uyBw7s8YoJHDLRFT6g7qgn0tcN
|
||||
ZufhNISvgWCVJQy/SZjNBHSpnIdCUSJAeTY2mkM4sGxY0Widk8LnjydxZUSxC3Nl
|
||||
hb6pnMh3jRq4h0+5CZielA4/a+TdrNPv/qok67ot/XJdY3qHCCd8O2b14OVq9jo=
|
||||
-----END CERTIFICATE-----
|
||||
28
lib/PsychicHttp/benchmark/psychichttps/data/server.key
Normal file
28
lib/PsychicHttp/benchmark/psychichttps/data/server.key
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCwYp7epz++0QkH
|
||||
JioMD7U7BitLgpcYPi8Cid1l7snt6Kp546iQsDBJ3l8xnRtPU7ANEsjT8KxIHmyw
|
||||
h/NGp94FlOKRw3ahh3yUGtowS9vdHv+S+TAfuj07NjSnKIyv5KnGZJ+fDFl4Q1tT
|
||||
aQJybY1Z4itirL6/2CGEm8g/iYhLNDBsRMfpDpfXe4URyWiM3Rhf7ztqZdveb9al
|
||||
3pAJZIDTLWCFQI1MvQjKamkAQkES/gZj0iUZFwbGJPBj54nkuLFLKedw7DbwgrVg
|
||||
0+n3fQ9b/gQepw5PxQjyobY2DsDgGZV+MFjUmaUTa+XX68SrG4wJ+DwrkdmpHReB
|
||||
vFi1Hg1hAgMBAAECggEAaTCnZkl/7qBjLexIryC/CBBJyaJ70W1kQ7NMYfniWwui
|
||||
f0aRxJgOdD81rjTvkINsPp+xPRQO6oOadjzdjImYEuQTqrJTEUnntbu924eh+2D9
|
||||
Mf2CAanj0mglRnscS9mmljZ0KzoGMX6Z/EhnuS40WiJTlWlH6MlQU/FDnwC6U34y
|
||||
JKy6/jGryfsx+kGU/NRvKSru6JYJWt5v7sOrymHWD62IT59h3blOiP8GMtYKeQlX
|
||||
49om9Mo1VTIFASY3lrxmexbY+6FG8YO+tfIe0tTAiGrkb9Pz6tYbaj9FjEWOv4Vc
|
||||
+3VMBUVdGJjgqvE8fx+/+mHo4Rg69BUPfPSrpEg7sQKBgQDlL85G04VZgrNZgOx6
|
||||
pTlCCl/NkfNb1OYa0BELqWINoWaWQHnm6lX8YjrUjwRpBF5s7mFhguFjUjp/NW6D
|
||||
0EEg5BmO0ePJ3dLKSeOA7gMo7y7kAcD/YGToqAaGljkBI+IAWK5Su5yldrECTQKG
|
||||
YnMKyQ1MWUfCYEwHtPvFvE5aPwKBgQDFBWXekpxHIvt/B41Cl/TftAzE7/f58JjV
|
||||
MFo/JCh9TDcH6N5TMTRS1/iQrv5M6kJSSrHnq8pqDXOwfHLwxetpk9tr937VRzoL
|
||||
CuG1Ar7c1AO6ujNnAEmUVC2DppL/ck5mRPWK/kgLwZSaNcZf8sydRgphsW1ogJin
|
||||
7g0nGbFwXwKBgQCPoZY07Pr1TeP4g8OwWTu5F6dSvdU2CAbtZthH5q98u1n/cAj1
|
||||
noak1Srpa3foGMTUn9CHu+5kwHPIpUPNeAZZBpq91uxa5pnkDMp3UrLIRJ2uZyr8
|
||||
4PxcknEEh8DR5hsM/IbDcrCJQglM19ZtQeW3LKkY4BsIxjDf45ymH407IQKBgE/g
|
||||
Ul6cPfOxQRlNLH4VMVgInSyyxWx1mODFy7DRrgCuh5kTVh+QUVBM8x9lcwAn8V9/
|
||||
nQT55wR8E603pznqY/jX0xvAqZE6YVPcw4kpZcwNwL1RhEl8GliikBlRzUL3SsW3
|
||||
q30AfqEViHPE3XpE66PPo6Hb1ymJCVr77iUuC3wtAoGBAIBrOGunv1qZMfqmwAY2
|
||||
lxlzRgxgSiaev0lTNxDzZkmU/u3dgdTwJ5DDANqPwJc6b8SGYTp9rQ0mbgVHnhIB
|
||||
jcJQBQkTfq6Z0H6OoTVi7dPs3ibQJFrtkoyvYAbyk36quBmNRjVh6rc8468bhXYr
|
||||
v/t+MeGJP/0Zw8v/X2CFll96
|
||||
-----END PRIVATE KEY-----
|
||||
BIN
lib/PsychicHttp/benchmark/psychichttps/data/www/alien.png
Normal file
BIN
lib/PsychicHttp/benchmark/psychichttps/data/www/alien.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
39
lib/PsychicHttp/benchmark/psychichttps/include/README
Normal file
39
lib/PsychicHttp/benchmark/psychichttps/include/README
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
46
lib/PsychicHttp/benchmark/psychichttps/lib/README
Normal file
46
lib/PsychicHttp/benchmark/psychichttps/lib/README
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
This directory is intended for project specific (private) libraries.
|
||||
PlatformIO will compile them to static libraries and link into executable file.
|
||||
|
||||
The source code of each library should be placed in a an own separate directory
|
||||
("lib/your_library_name/[here are source files]").
|
||||
|
||||
For example, see a structure of the following two libraries `Foo` and `Bar`:
|
||||
|
||||
|--lib
|
||||
| |
|
||||
| |--Bar
|
||||
| | |--docs
|
||||
| | |--examples
|
||||
| | |--src
|
||||
| | |- Bar.c
|
||||
| | |- Bar.h
|
||||
| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|
||||
| |
|
||||
| |--Foo
|
||||
| | |- Foo.c
|
||||
| | |- Foo.h
|
||||
| |
|
||||
| |- README --> THIS FILE
|
||||
|
|
||||
|- platformio.ini
|
||||
|--src
|
||||
|- main.c
|
||||
|
||||
and a contents of `src/main.c`:
|
||||
```
|
||||
#include <Foo.h>
|
||||
#include <Bar.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
PlatformIO Library Dependency Finder will find automatically dependent
|
||||
libraries scanning project source files.
|
||||
|
||||
More information about PlatformIO Library Dependency Finder
|
||||
- https://docs.platformio.org/page/librarymanager/ldf.html
|
||||
22
lib/PsychicHttp/benchmark/psychichttps/platformio.ini
Normal file
22
lib/PsychicHttp/benchmark/psychichttps/platformio.ini
Normal file
@@ -0,0 +1,22 @@
|
||||
; PlatformIO Project Configuration File
|
||||
;
|
||||
; Build options: build flags, source filter
|
||||
; Upload options: custom upload port, speed and extra flags
|
||||
; Library options: dependencies, extra library storages
|
||||
; Advanced options: extra scripting
|
||||
;
|
||||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env]
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
board = esp32dev
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder
|
||||
lib_deps =
|
||||
https://github.com/hoeken/PsychicHttp
|
||||
bblanchon/ArduinoJson
|
||||
board_build.filesystem = littlefs
|
||||
|
||||
[env:default]
|
||||
240
lib/PsychicHttp/benchmark/psychichttps/src/main.cpp
Normal file
240
lib/PsychicHttp/benchmark/psychichttps/src/main.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
/* Wi-Fi STA Connect and Disconnect Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
#include <PsychicHttp.h>
|
||||
#include <LittleFS.h>
|
||||
#include <ArduinoJSON.h>
|
||||
#include "_secret.h"
|
||||
#include <PsychicHttp.h>
|
||||
#include <PsychicHttpsServer.h>
|
||||
|
||||
#ifndef WIFI_SSID
|
||||
#error "You need to enter your wifi credentials. Rename secret.h to _secret.h and enter your credentials there."
|
||||
#endif
|
||||
|
||||
//Enter your WIFI credentials in secret.h
|
||||
const char *ssid = WIFI_SSID;
|
||||
const char *password = WIFI_PASS;
|
||||
|
||||
PsychicHttpsServer server;
|
||||
PsychicWebSocketHandler websocketHandler;
|
||||
|
||||
String server_cert;
|
||||
String server_key;
|
||||
|
||||
const char *htmlContent = R"(
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Sample HTML</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello, World!</h1>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin euismod, purus a euismod
|
||||
rhoncus, urna ipsum cursus massa, eu dictum tellus justo ac justo. Quisque ullamcorper
|
||||
arcu nec tortor ullamcorper, vel fermentum justo fermentum. Vivamus sed velit ut elit
|
||||
accumsan congue ut ut enim. Ut eu justo eu lacus varius gravida ut a tellus. Nulla facilisi.
|
||||
Integer auctor consectetur ultricies. Fusce feugiat, mi sit amet bibendum viverra, orci leo
|
||||
dapibus elit, id varius sem dui id lacus.</p>
|
||||
</body>
|
||||
</html>
|
||||
)";
|
||||
|
||||
bool connectToWifi()
|
||||
{
|
||||
Serial.println();
|
||||
Serial.print("[WiFi] Connecting to ");
|
||||
Serial.println(ssid);
|
||||
|
||||
WiFi.setSleep(false);
|
||||
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
// Will try for about 10 seconds (20x 500ms)
|
||||
int tryDelay = 500;
|
||||
int numberOfTries = 20;
|
||||
|
||||
// Wait for the WiFi event
|
||||
while (true)
|
||||
{
|
||||
switch (WiFi.status())
|
||||
{
|
||||
case WL_NO_SSID_AVAIL:
|
||||
Serial.println("[WiFi] SSID not found");
|
||||
break;
|
||||
case WL_CONNECT_FAILED:
|
||||
Serial.print("[WiFi] Failed - WiFi not connected! Reason: ");
|
||||
return false;
|
||||
break;
|
||||
case WL_CONNECTION_LOST:
|
||||
Serial.println("[WiFi] Connection was lost");
|
||||
break;
|
||||
case WL_SCAN_COMPLETED:
|
||||
Serial.println("[WiFi] Scan is completed");
|
||||
break;
|
||||
case WL_DISCONNECTED:
|
||||
Serial.println("[WiFi] WiFi is disconnected");
|
||||
break;
|
||||
case WL_CONNECTED:
|
||||
Serial.println("[WiFi] WiFi is connected!");
|
||||
Serial.print("[WiFi] IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
Serial.print("[WiFi] WiFi Status: ");
|
||||
Serial.println(WiFi.status());
|
||||
break;
|
||||
}
|
||||
delay(tryDelay);
|
||||
|
||||
if (numberOfTries <= 0)
|
||||
{
|
||||
Serial.print("[WiFi] Failed to connect to WiFi!");
|
||||
// Use disconnect function to force stop trying to connect
|
||||
WiFi.disconnect();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
numberOfTries--;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
delay(10);
|
||||
Serial.println("PsychicHTTP Benchmark");
|
||||
|
||||
if (connectToWifi())
|
||||
{
|
||||
if(!LittleFS.begin())
|
||||
{
|
||||
Serial.println("LittleFS Mount Failed. Do Platform -> Build Filesystem Image and Platform -> Upload Filesystem Image from VSCode");
|
||||
return;
|
||||
}
|
||||
|
||||
File fp = LittleFS.open("/server.crt");
|
||||
if (fp) {
|
||||
server_cert = fp.readString();
|
||||
} else {
|
||||
Serial.println("server.pem not found, SSL not available");
|
||||
return;
|
||||
}
|
||||
fp.close();
|
||||
|
||||
File fp2 = LittleFS.open("/server.key");
|
||||
if (fp2) {
|
||||
server_key = fp2.readString();
|
||||
} else {
|
||||
Serial.println("server.key not found, SSL not available");
|
||||
return;
|
||||
}
|
||||
fp2.close();
|
||||
|
||||
//start our server
|
||||
server.listen(443, server_cert.c_str(), server_key.c_str());
|
||||
|
||||
//our index
|
||||
server.on("/", HTTP_GET, [](PsychicRequest *request)
|
||||
{
|
||||
return request->reply(200, "text/html", htmlContent);
|
||||
});
|
||||
|
||||
//serve static files from LittleFS/www on /
|
||||
server.serveStatic("/", LittleFS, "/www/");
|
||||
|
||||
//a websocket echo server
|
||||
websocketHandler.onFrame([](PsychicWebSocketRequest *request, httpd_ws_frame *frame) {
|
||||
request->reply(frame);
|
||||
return ESP_OK;
|
||||
});
|
||||
server.on("/ws", &websocketHandler);
|
||||
|
||||
//api - parameters passed in via query eg. /api/endpoint?foo=bar
|
||||
server.on("/api", HTTP_GET, [](PsychicRequest *request)
|
||||
{
|
||||
//create a response object
|
||||
StaticJsonDocument<128> output;
|
||||
output["msg"] = "status";
|
||||
output["status"] = "success";
|
||||
output["millis"] = millis();
|
||||
|
||||
//work with some params
|
||||
if (request->hasParam("foo"))
|
||||
{
|
||||
String foo = request->getParam("foo")->value();
|
||||
output["foo"] = foo;
|
||||
}
|
||||
|
||||
//serialize and return
|
||||
String jsonBuffer;
|
||||
serializeJson(output, jsonBuffer);
|
||||
return request->reply(200, "application/json", jsonBuffer.c_str());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long last;
|
||||
void loop()
|
||||
{
|
||||
if (millis() - last > 1000)
|
||||
{
|
||||
Serial.printf("Free Heap: %d\n", esp_get_free_heap_size());
|
||||
last = millis();
|
||||
}
|
||||
}
|
||||
2
lib/PsychicHttp/benchmark/psychichttps/src/secret.h
Normal file
2
lib/PsychicHttp/benchmark/psychichttps/src/secret.h
Normal file
@@ -0,0 +1,2 @@
|
||||
#define WIFI_SSID "Your_SSID"
|
||||
#define WIFI_PASS "Your_PASS"
|
||||
11
lib/PsychicHttp/benchmark/psychichttps/test/README
Normal file
11
lib/PsychicHttp/benchmark/psychichttps/test/README
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
control data, usage procedures, and operating procedures, are tested to
|
||||
determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||
1172
lib/PsychicHttp/benchmark/results/arduinomongoose-http-loadtest.log
Normal file
1172
lib/PsychicHttp/benchmark/results/arduinomongoose-http-loadtest.log
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,246 @@
|
||||
|
||||
|
||||
CLIENTS: *** 1 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 1
|
||||
Agent: none
|
||||
|
||||
Completed requests: 3750
|
||||
Total errors: 0
|
||||
Total time: 60.001 s
|
||||
Mean latency: 15.5 ms
|
||||
Effective rps: 62
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 12 ms
|
||||
90% 18 ms
|
||||
95% 36 ms
|
||||
99% 80 ms
|
||||
100% 223 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 2 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 5795
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 20.2 ms
|
||||
Effective rps: 97
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 16 ms
|
||||
90% 27 ms
|
||||
95% 64 ms
|
||||
99% 86 ms
|
||||
100% 108 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 3 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 3
|
||||
Agent: none
|
||||
|
||||
Completed requests: 7445
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 23.6 ms
|
||||
Effective rps: 124
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 19 ms
|
||||
90% 32 ms
|
||||
95% 70 ms
|
||||
99% 92 ms
|
||||
100% 121 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 4 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 4
|
||||
Agent: none
|
||||
|
||||
Completed requests: 8751
|
||||
Total errors: 0
|
||||
Total time: 60.005 s
|
||||
Mean latency: 26.9 ms
|
||||
Effective rps: 146
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 22 ms
|
||||
90% 38 ms
|
||||
95% 73 ms
|
||||
99% 95 ms
|
||||
100% 115 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 5 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 5
|
||||
Agent: none
|
||||
|
||||
Completed requests: 9953
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 29.6 ms
|
||||
Effective rps: 166
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 25 ms
|
||||
90% 42 ms
|
||||
95% 74 ms
|
||||
99% 93 ms
|
||||
100% 116 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 6 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 6
|
||||
Agent: none
|
||||
|
||||
Completed requests: 10871
|
||||
Total errors: 0
|
||||
Total time: 60.005 s
|
||||
Mean latency: 32.6 ms
|
||||
Effective rps: 181
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 27 ms
|
||||
90% 50 ms
|
||||
95% 82 ms
|
||||
99% 100 ms
|
||||
100% 116 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 7 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 7
|
||||
Agent: none
|
||||
|
||||
Completed requests: 11777
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 35.1 ms
|
||||
Effective rps: 196
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 30 ms
|
||||
90% 66 ms
|
||||
95% 83 ms
|
||||
99% 101 ms
|
||||
100% 137 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 8 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 8
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 11639
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 35.4 ms
|
||||
Effective rps: 194
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 30 ms
|
||||
90% 67 ms
|
||||
95% 86 ms
|
||||
99% 106 ms
|
||||
100% 135 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 10 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 10
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 11619
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 35.6 ms
|
||||
Effective rps: 194
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 30 ms
|
||||
90% 71 ms
|
||||
95% 87 ms
|
||||
99% 105 ms
|
||||
100% 125 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 16 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 16
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 15314
|
||||
Total errors: 0
|
||||
Total time: 60.005 s
|
||||
Mean latency: 54.2 ms
|
||||
Effective rps: 255
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 46 ms
|
||||
90% 91 ms
|
||||
95% 105 ms
|
||||
99% 127 ms
|
||||
100% 826 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 20 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 20
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 15370
|
||||
Total errors: 0
|
||||
Total time: 60.005 s
|
||||
Mean latency: 57.7 ms
|
||||
Effective rps: 256
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 48 ms
|
||||
90% 96 ms
|
||||
95% 110 ms
|
||||
99% 132 ms
|
||||
100% 851 ms (longest request)
|
||||
1165
lib/PsychicHttp/benchmark/results/espasync-http-loadtest.log
Normal file
1165
lib/PsychicHttp/benchmark/results/espasync-http-loadtest.log
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,252 @@
|
||||
|
||||
|
||||
CLIENTS: *** 1 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 1
|
||||
Agent: none
|
||||
|
||||
Completed requests: 4231
|
||||
Total errors: 0
|
||||
Total time: 60.002 s
|
||||
Mean latency: 13.6 ms
|
||||
Effective rps: 71
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 10 ms
|
||||
90% 16 ms
|
||||
95% 24 ms
|
||||
99% 81 ms
|
||||
100% 280 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 2 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 5914
|
||||
Total errors: 0
|
||||
Total time: 60.001 s
|
||||
Mean latency: 19.7 ms
|
||||
Effective rps: 99
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 15 ms
|
||||
90% 26 ms
|
||||
95% 67 ms
|
||||
99% 86 ms
|
||||
100% 109 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 3 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 3
|
||||
Agent: none
|
||||
|
||||
Completed requests: 8204
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 21.4 ms
|
||||
Effective rps: 137
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 17 ms
|
||||
90% 29 ms
|
||||
95% 68 ms
|
||||
99% 87 ms
|
||||
100% 104 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 4 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 4
|
||||
Agent: none
|
||||
|
||||
Completed requests: 9634
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 24.4 ms
|
||||
Effective rps: 161
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 19 ms
|
||||
90% 33 ms
|
||||
95% 73 ms
|
||||
99% 91 ms
|
||||
100% 145 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 5 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 5
|
||||
Agent: none
|
||||
|
||||
Completed requests: 10759
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 27.3 ms
|
||||
Effective rps: 179
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 22 ms
|
||||
90% 39 ms
|
||||
95% 76 ms
|
||||
99% 95 ms
|
||||
100% 117 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 6 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 6
|
||||
Agent: none
|
||||
|
||||
Completed requests: 11302
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 31.3 ms
|
||||
Effective rps: 188
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 26 ms
|
||||
90% 58 ms
|
||||
95% 81 ms
|
||||
99% 100 ms
|
||||
100% 122 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 7 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 7
|
||||
Agent: none
|
||||
|
||||
Completed requests: 12713
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 32.5 ms
|
||||
Effective rps: 212
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 27 ms
|
||||
90% 52 ms
|
||||
95% 81 ms
|
||||
99% 99 ms
|
||||
100% 125 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 8 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 8
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 13157
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 35.9 ms
|
||||
Effective rps: 219
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 30 ms
|
||||
90% 71 ms
|
||||
95% 88 ms
|
||||
99% 107 ms
|
||||
100% 132 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 10 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 10
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 13417
|
||||
Total errors: 2
|
||||
Total time: 60.001 s
|
||||
Mean latency: 34.4 ms
|
||||
Effective rps: 224
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 30 ms
|
||||
90% 53 ms
|
||||
95% 81 ms
|
||||
99% 101 ms
|
||||
100% 124 ms (longest request)
|
||||
|
||||
-1: 2 errors
|
||||
|
||||
|
||||
CLIENTS: *** 16 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 16
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 12804
|
||||
Total errors: 7
|
||||
Total time: 60.001 s
|
||||
Mean latency: 36.4 ms
|
||||
Effective rps: 213
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 30 ms
|
||||
90% 70 ms
|
||||
95% 86 ms
|
||||
99% 106 ms
|
||||
100% 135 ms (longest request)
|
||||
|
||||
-1: 7 errors
|
||||
|
||||
|
||||
CLIENTS: *** 20 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 20
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 8421
|
||||
Total errors: 13
|
||||
Total time: 60.003 s
|
||||
Mean latency: 37.2 ms
|
||||
Effective rps: 140
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 20 ms
|
||||
90% 50 ms
|
||||
95% 77 ms
|
||||
99% 105 ms
|
||||
100% 9227 ms (longest request)
|
||||
|
||||
-1: 13 errors
|
||||
1172
lib/PsychicHttp/benchmark/results/psychic-http-loadtest.log
Normal file
1172
lib/PsychicHttp/benchmark/results/psychic-http-loadtest.log
Normal file
File diff suppressed because it is too large
Load Diff
1194
lib/PsychicHttp/benchmark/results/psychic-ssl-http-loadtest.log
Normal file
1194
lib/PsychicHttp/benchmark/results/psychic-ssl-http-loadtest.log
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,246 @@
|
||||
|
||||
|
||||
CLIENTS: *** 1 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 1
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2039
|
||||
Total errors: 0
|
||||
Total time: 60.002 s
|
||||
Mean latency: 27.8 ms
|
||||
Effective rps: 34
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 24 ms
|
||||
90% 34 ms
|
||||
95% 62 ms
|
||||
99% 97 ms
|
||||
100% 109 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 2 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2969
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 37.7 ms
|
||||
Effective rps: 49
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 32 ms
|
||||
90% 52 ms
|
||||
95% 92 ms
|
||||
99% 110 ms
|
||||
100% 126 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 3 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 3
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2883
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 38.2 ms
|
||||
Effective rps: 48
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 32 ms
|
||||
90% 52 ms
|
||||
95% 86 ms
|
||||
99% 109 ms
|
||||
100% 1711 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 4 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 4
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2858
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 37.9 ms
|
||||
Effective rps: 48
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 32 ms
|
||||
90% 49 ms
|
||||
95% 76 ms
|
||||
99% 104 ms
|
||||
100% 1740 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 5 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 5
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2772
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 38.6 ms
|
||||
Effective rps: 46
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 32 ms
|
||||
90% 49 ms
|
||||
95% 79 ms
|
||||
99% 106 ms
|
||||
100% 1634 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 6 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 6
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2722
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 38.7 ms
|
||||
Effective rps: 45
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 32 ms
|
||||
90% 49 ms
|
||||
95% 72 ms
|
||||
99% 102 ms
|
||||
100% 1694 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 7 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 7
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2552
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 40.7 ms
|
||||
Effective rps: 43
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 32 ms
|
||||
90% 52 ms
|
||||
95% 86 ms
|
||||
99% 112 ms
|
||||
100% 1816 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 8 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 8
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2507
|
||||
Total errors: 0
|
||||
Total time: 60.005 s
|
||||
Mean latency: 40.8 ms
|
||||
Effective rps: 42
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 32 ms
|
||||
90% 50 ms
|
||||
95% 80 ms
|
||||
99% 112 ms
|
||||
100% 1646 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 10 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 10
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2265
|
||||
Total errors: 0
|
||||
Total time: 60.008 s
|
||||
Mean latency: 43.7 ms
|
||||
Effective rps: 38
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 33 ms
|
||||
90% 52 ms
|
||||
95% 79 ms
|
||||
99% 114 ms
|
||||
100% 1675 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 16 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 16
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 1795
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 49.7 ms
|
||||
Effective rps: 30
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 33 ms
|
||||
90% 51 ms
|
||||
95% 77 ms
|
||||
99% 112 ms
|
||||
100% 1741 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 20 ***
|
||||
|
||||
|
||||
Target URL: wss://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 20
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 1603
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 54.1 ms
|
||||
Effective rps: 27
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 33 ms
|
||||
90% 60 ms
|
||||
95% 94 ms
|
||||
99% 133 ms
|
||||
100% 1729 ms (longest request)
|
||||
1179
lib/PsychicHttp/benchmark/results/psychic-v1.1-http-loadtest.log
Normal file
1179
lib/PsychicHttp/benchmark/results/psychic-v1.1-http-loadtest.log
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,246 @@
|
||||
|
||||
|
||||
CLIENTS: *** 1 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 1
|
||||
Agent: none
|
||||
|
||||
Completed requests: 1972
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 29.8 ms
|
||||
Effective rps: 33
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 25 ms
|
||||
90% 40 ms
|
||||
95% 66 ms
|
||||
99% 96 ms
|
||||
100% 147 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 2 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 3144
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 37.6 ms
|
||||
Effective rps: 52
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 32 ms
|
||||
90% 58 ms
|
||||
95% 82 ms
|
||||
99% 114 ms
|
||||
100% 160 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 3 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 3
|
||||
Agent: none
|
||||
|
||||
Completed requests: 4113
|
||||
Total errors: 0
|
||||
Total time: 60.005 s
|
||||
Mean latency: 43.2 ms
|
||||
Effective rps: 69
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 38 ms
|
||||
90% 63 ms
|
||||
95% 88 ms
|
||||
99% 119 ms
|
||||
100% 339 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 4 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 4
|
||||
Agent: none
|
||||
|
||||
Completed requests: 4902
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 48.3 ms
|
||||
Effective rps: 82
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 42 ms
|
||||
90% 74 ms
|
||||
95% 97 ms
|
||||
99% 125 ms
|
||||
100% 217 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 5 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 5
|
||||
Agent: none
|
||||
|
||||
Completed requests: 5522
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 53.7 ms
|
||||
Effective rps: 92
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 48 ms
|
||||
90% 81 ms
|
||||
95% 102 ms
|
||||
99% 122 ms
|
||||
100% 324 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 6 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 6
|
||||
Agent: none
|
||||
|
||||
Completed requests: 5808
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 61.4 ms
|
||||
Effective rps: 97
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 54 ms
|
||||
90% 94 ms
|
||||
95% 117 ms
|
||||
99% 142 ms
|
||||
100% 348 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 7 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 7
|
||||
Agent: none
|
||||
|
||||
Completed requests: 6478
|
||||
Total errors: 0
|
||||
Total time: 60.006 s
|
||||
Mean latency: 64.1 ms
|
||||
Effective rps: 108
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 59 ms
|
||||
90% 94 ms
|
||||
95% 110 ms
|
||||
99% 137 ms
|
||||
100% 195 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 8 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 8
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 6124
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 67.8 ms
|
||||
Effective rps: 102
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 59 ms
|
||||
90% 107 ms
|
||||
95% 131 ms
|
||||
99% 173 ms
|
||||
100% 260 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 10 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 10
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 5640
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 73.7 ms
|
||||
Effective rps: 94
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 61 ms
|
||||
90% 120 ms
|
||||
95% 140 ms
|
||||
99% 240 ms
|
||||
100% 780 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 16 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 16
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 5809
|
||||
Total errors: 0
|
||||
Total time: 60.006 s
|
||||
Mean latency: 71.6 ms
|
||||
Effective rps: 97
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 64 ms
|
||||
90% 111 ms
|
||||
95% 130 ms
|
||||
99% 162 ms
|
||||
100% 226 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 20 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 20
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 5590
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 74.4 ms
|
||||
Effective rps: 93
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 61 ms
|
||||
90% 122 ms
|
||||
95% 151 ms
|
||||
99% 247 ms
|
||||
100% 513 ms (longest request)
|
||||
246
lib/PsychicHttp/benchmark/results/psychic-websocket-loadtest.log
Normal file
246
lib/PsychicHttp/benchmark/results/psychic-websocket-loadtest.log
Normal file
@@ -0,0 +1,246 @@
|
||||
|
||||
|
||||
CLIENTS: *** 1 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 1
|
||||
Agent: none
|
||||
|
||||
Completed requests: 2304
|
||||
Total errors: 0
|
||||
Total time: 60.002 s
|
||||
Mean latency: 25.5 ms
|
||||
Effective rps: 38
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 22 ms
|
||||
90% 32 ms
|
||||
95% 58 ms
|
||||
99% 92 ms
|
||||
100% 105 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 2 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 3647
|
||||
Total errors: 0
|
||||
Total time: 60.002 s
|
||||
Mean latency: 32.3 ms
|
||||
Effective rps: 61
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 28 ms
|
||||
90% 43 ms
|
||||
95% 67 ms
|
||||
99% 93 ms
|
||||
100% 135 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 3 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 3
|
||||
Agent: none
|
||||
|
||||
Completed requests: 4629
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 38.3 ms
|
||||
Effective rps: 77
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 34 ms
|
||||
90% 51 ms
|
||||
95% 79 ms
|
||||
99% 110 ms
|
||||
100% 152 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 4 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 4
|
||||
Agent: none
|
||||
|
||||
Completed requests: 5290
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 44.7 ms
|
||||
Effective rps: 88
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 40 ms
|
||||
90% 67 ms
|
||||
95% 92 ms
|
||||
99% 115 ms
|
||||
100% 159 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 5 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 5
|
||||
Agent: none
|
||||
|
||||
Completed requests: 5935
|
||||
Total errors: 0
|
||||
Total time: 60.002 s
|
||||
Mean latency: 50 ms
|
||||
Effective rps: 99
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 45 ms
|
||||
90% 74 ms
|
||||
95% 97 ms
|
||||
99% 123 ms
|
||||
100% 172 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 6 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 6
|
||||
Agent: none
|
||||
|
||||
Completed requests: 6533
|
||||
Total errors: 0
|
||||
Total time: 60.003 s
|
||||
Mean latency: 54.5 ms
|
||||
Effective rps: 109
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 49 ms
|
||||
90% 78 ms
|
||||
95% 101 ms
|
||||
99% 129 ms
|
||||
100% 170 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 7 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 7
|
||||
Agent: none
|
||||
|
||||
Completed requests: 7086
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 58.6 ms
|
||||
Effective rps: 118
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 54 ms
|
||||
90% 85 ms
|
||||
95% 107 ms
|
||||
99% 130 ms
|
||||
100% 184 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 8 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 8
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 6994
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 59.3 ms
|
||||
Effective rps: 117
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 54 ms
|
||||
90% 88 ms
|
||||
95% 109 ms
|
||||
99% 134 ms
|
||||
100% 176 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 10 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 10
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 7197
|
||||
Total errors: 0
|
||||
Total time: 60.004 s
|
||||
Mean latency: 57.7 ms
|
||||
Effective rps: 120
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 53 ms
|
||||
90% 83 ms
|
||||
95% 98 ms
|
||||
99% 123 ms
|
||||
100% 176 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 16 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 16
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 7173
|
||||
Total errors: 0
|
||||
Total time: 60.002 s
|
||||
Mean latency: 57.9 ms
|
||||
Effective rps: 120
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 53 ms
|
||||
90% 83 ms
|
||||
95% 100 ms
|
||||
99% 123 ms
|
||||
100% 156 ms (longest request)
|
||||
|
||||
|
||||
CLIENTS: *** 20 ***
|
||||
|
||||
|
||||
Target URL: ws://192.168.2.131/ws
|
||||
Max time (s): 60
|
||||
Concurrent clients: 20
|
||||
Running on cores: 2
|
||||
Agent: none
|
||||
|
||||
Completed requests: 6883
|
||||
Total errors: 0
|
||||
Total time: 60.002 s
|
||||
Mean latency: 60.4 ms
|
||||
Effective rps: 115
|
||||
|
||||
Percentage of requests served within a certain time
|
||||
50% 55 ms
|
||||
90% 92 ms
|
||||
95% 111 ms
|
||||
99% 138 ms
|
||||
100% 175 ms (longest request)
|
||||
36
lib/PsychicHttp/benchmark/websocket-client-test.js
Normal file
36
lib/PsychicHttp/benchmark/websocket-client-test.js
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const WebSocket = require('ws');
|
||||
|
||||
const uri = 'ws://192.168.2.131/ws';
|
||||
|
||||
async function websocketClient() {
|
||||
console.log(`Starting test`);
|
||||
for (let i = 0; i < 1000000; i++) {
|
||||
const ws = new WebSocket(uri);
|
||||
|
||||
if (i % 100 == 0)
|
||||
console.log(`Count: ${i}`);
|
||||
|
||||
ws.on('open', () => {
|
||||
//console.log(`Connected`);
|
||||
});
|
||||
|
||||
ws.on('message', (message) => {
|
||||
//console.log(`Message: ${message}`);
|
||||
ws.close();
|
||||
});
|
||||
|
||||
ws.on('error', (error) => {
|
||||
console.error(`Error: ${error.message}`);
|
||||
});
|
||||
|
||||
await new Promise((resolve) => {
|
||||
ws.on('close', () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
websocketClient();
|
||||
Reference in New Issue
Block a user