public
Last active

An example of request/response using api-benchmark with node.js https://github.com/matteofigus/api-benchmark

  • Download Gist
api-benchmark-example.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
var apiBenchmark = require('api-benchmark');
var services = {
".NET": "http://localhost:57382/my-api/v1/",
"nodeJS": "http://localhost:3000/my-api/v1/"
};
var routes = {
"getUsers": "users/get",
"getUserInfo": "users/12345/get-info"
};
var options = { debug: true, minSamples: 100, maxTime: 5 };
apiBenchmark.compare(services, routes, options, function(err, results){
console.log(results);
/* displays:
.NET/getUsers x 58.37 ops/sec ±16.98% (173 runs sampled)
nodeJS/getUsers x 188 ops/sec ±0.99% (179 runs sampled)
======================================
Fastest is nodeJS/getUsers
 
.NET/getUserInfo x 49.16 ops/sec ±12.71% (153 runs sampled)
nodeJS/getUserInfo x 106 ops/sec ±1.19% (180 runs sampled)
======================================
Fastest is nodeJS/getUserInfo
 
======================================
Fastest Service is nodeJS
{ '.NET':
{ getUsers:
{ name: '.NET/getUsers',
href: 'http://localhost:57382/my-api/v1/users/get',
stats: [Object],
cycles: 3,
hz: 58.36824401380643 },
'getUserInfo':
{ name: '.NET/getUserInfo',
href: 'http://localhost:57382/my-api/v1/users/12345/get-info',
stats: [Object],
cycles: 3,
hz: 49.16409187790408 },
isSlowest: true },
nodeJS:
{ getUsers:
{ name: 'nodeJS/getUsers',
href: 'http://localhost:3000/my-api/v1/users/get',
stats: [Object],
cycles: 2,
hz: 187.5014849827169 },
'getUserInfo':
{ name: 'nodeJS/getUserInfo',
href: 'http://localhost:3000/my-api/v1/users/12345/get-info',
stats: [Object],
cycles: 3,
hz: 105.85228376312513 },
isFastest: true } }
*/
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.