loadtest 6.2.1 → 6.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/testserver.js +18 -7
- package/package.json +1 -1
package/lib/testserver.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as net from 'net'
|
|
|
5
5
|
import {Latency} from './latency.js'
|
|
6
6
|
|
|
7
7
|
const PORT = 7357;
|
|
8
|
-
const
|
|
8
|
+
const LOG_HEADERS_INTERVAL_MS = 5000;
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -18,6 +18,7 @@ class TestServer {
|
|
|
18
18
|
this.server = null;
|
|
19
19
|
this.wsServer = null;
|
|
20
20
|
this.latency = new Latency({});
|
|
21
|
+
this.totalRequests = 0
|
|
21
22
|
this.debuggedTime = Date.now();
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -82,10 +83,10 @@ class TestServer {
|
|
|
82
83
|
request.body += data.toString();
|
|
83
84
|
});
|
|
84
85
|
request.on('end', () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.
|
|
86
|
+
this.totalRequests += 1
|
|
87
|
+
const elapsedMs = Date.now() - this.debuggedTime
|
|
88
|
+
if (elapsedMs > LOG_HEADERS_INTERVAL_MS) {
|
|
89
|
+
this.debug(request, elapsedMs);
|
|
89
90
|
}
|
|
90
91
|
if (!this.options.delay) {
|
|
91
92
|
return this.end(response, id);
|
|
@@ -118,10 +119,20 @@ class TestServer {
|
|
|
118
119
|
* Debug headers and other interesting information: POST body.
|
|
119
120
|
*/
|
|
120
121
|
debug(request) {
|
|
121
|
-
if (
|
|
122
|
+
if (this.options.quiet) return
|
|
123
|
+
const headers = util.inspect(request.headers)
|
|
124
|
+
const now = Date.now()
|
|
125
|
+
const elapsedMs = now - this.debuggedTime
|
|
126
|
+
const rps = (this.totalRequests / elapsedMs) * 1000
|
|
127
|
+
if (rps > 1) {
|
|
128
|
+
console.info(`Requests per second: ${rps.toFixed(0)}`)
|
|
129
|
+
}
|
|
130
|
+
console.info(`Headers for ${request.method} to ${request.url}: ${headers}`)
|
|
122
131
|
if (request.body) {
|
|
123
|
-
|
|
132
|
+
console.info(`Body: ${request.body}`);
|
|
124
133
|
}
|
|
134
|
+
this.debuggedTime = now;
|
|
135
|
+
this.totalRequests = 0
|
|
125
136
|
}
|
|
126
137
|
|
|
127
138
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loadtest",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Run load tests for your web application. Mostly ab-compatible interface, with an option to force requests per second. Includes an API for automated load testing.",
|
|
6
6
|
"homepage": "https://github.com/alexfernandez/loadtest",
|