Skip to content

Commit

Permalink
Improved Benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
kartikk221 committed Apr 25, 2022
1 parent 82a80e8 commit 81360b1
Show file tree
Hide file tree
Showing 4 changed files with 396 additions and 223 deletions.
1 change: 1 addition & 0 deletions benchmarks/configuration.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"hostname": "localhost",
"port_start": 3000,
"multi_core": false
}
18 changes: 11 additions & 7 deletions benchmarks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { log } from './utils.js';

// Load the server instances to be benchmarked
import uWebsockets from './setup/uwebsockets.js';
import NanoExpress from './setup/nanoexpress.js';
// import NanoExpress from './setup/nanoexpress.js';
import HyperExpress from './setup/hyperexpress.js';
import Fastify from './setup/fastify.js';
import Express from './setup/express.js';
Expand All @@ -33,27 +33,31 @@ let uws_socket;
const initial_port = configuration.port_start;

// Initialize the uWebsockets server instance
uws_socket = await new Promise((resolve) => uWebsockets.listen(configuration.port_start, resolve));
uws_socket = await new Promise((resolve) =>
uWebsockets.listen(configuration.hostname, configuration.port_start, resolve)
);
log(`uWebsockets.js server listening on port ${configuration.port_start}`);

// Initialize the NanoExpress server instance
configuration.port_start++;
// Commented out NanoExpress as it is not properly updated to Node.js v18
/* configuration.port_start++;
await NanoExpress.listen(configuration.port_start);
log(`NanoExpress server listening on port ${configuration.port_start}`);
*/

// Initialize the NanoExpress server instance
configuration.port_start++;
await HyperExpress.listen(configuration.port_start);
await HyperExpress.listen(configuration.port_start, configuration.hostname);
log(`HyperExpress server listening on port ${configuration.port_start}`);

// Initialize the Fastify server instance
configuration.port_start++;
await Fastify.listen(configuration.port_start);
await Fastify.listen(configuration.port_start, configuration.hostname);
log(`Fastify server listening on port ${configuration.port_start}`);

// Initialize the Express server instance
configuration.port_start++;
await new Promise((resolve) => Express.listen(configuration.port_start, resolve));
await new Promise((resolve) => Express.listen(configuration.port_start, configuration.hostname, resolve));
log(`Express.js server listening on port ${configuration.port_start}`);

// Make HTTP GET requests to all used ports to test the servers
Expand Down Expand Up @@ -83,7 +87,7 @@ let uws_socket;
// Close all the webserver instances
try {
uWebsocketsJS.us_listen_socket_close(uws_socket);
NanoExpress.close();
// NanoExpress.close();
HyperExpress.close();
Fastify.close();
} catch (error) {
Expand Down
Loading

0 comments on commit 81360b1

Please sign in to comment.