mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 17:29:50 +03:00
latest updates
This commit is contained in:
39
benchmark/http-client-test.js
Executable file
39
benchmark/http-client-test.js
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const axios = require('axios');
|
||||
|
||||
const url = 'http://10.10.10.135/api/system/commands';
|
||||
const queryParams = {
|
||||
entity: 'commands',
|
||||
id: 0
|
||||
};
|
||||
|
||||
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();
|
||||
38
benchmark/loadtest-http.sh
Executable file
38
benchmark/loadtest-http.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install:
|
||||
# npm install -g autocannon
|
||||
# yarn global add autocannon
|
||||
#
|
||||
# or run https://github.com/nearform/autocannon-ui
|
||||
|
||||
TEST_IP="10.10.10.135"
|
||||
TEST_TIME=60
|
||||
LOG_FILE=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 1
|
||||
#for CONCURRENCY in 20
|
||||
do
|
||||
printf "\n\nCLIENTS: *** $CONCURRENCY ***\n\n" >> $LOG_FILE
|
||||
echo "Testing $CONCURRENCY clients on $PROTOCOL://$TEST_IP/"
|
||||
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/system/commands"
|
||||
autocannon -c $CONCURRENCY -w 1 -d $TEST_TIME --renderStatusCodes "$PROTOCOL://$TEST_IP/api/system/commands" >> $LOG_FILE 2>&1
|
||||
printf "\n\n----------------\n\n" >> $LOG_FILE
|
||||
sleep 1
|
||||
|
||||
echo "Testing $CONCURRENCY clients on $PROTOCOL://$TEST_IP/app/icon.png"
|
||||
autocannon -c $CONCURRENCY -w 1 -d $TEST_TIME --renderStatusCodes "$PROTOCOL://$TEST_IP/app/icon.png" >> $LOG_FILE 2>&1
|
||||
printf "\n\n----------------\n\n" >> $LOG_FILE
|
||||
sleep 1
|
||||
done
|
||||
8
benchmark/package.json
Normal file
8
benchmark/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"autocannon": "^7.14.0",
|
||||
"axios": "^1.6.2",
|
||||
"eventsource": "^2.0.2",
|
||||
"ws": "^8.14.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user