Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add node@7 async function test #1

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions koa2/.babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["es2015-node5","stage-3"]
}
"presets": ["es2017-node7"]
}
52 changes: 24 additions & 28 deletions koa2/koa2-async-compile.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,39 @@

'use strict';

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { return step("next", value); }, function (err) { return step("throw", err); }); } } return step("next"); }); }; }
Object.defineProperty(exports, "__esModule", {
value: true
});

var http = require('http');
var koa = require('koa');
var app = new koa();
var _http = require('http');

// number of middleware
var _http2 = _interopRequireDefault(_http);

var _koa = require('koa');

var _koa2 = _interopRequireDefault(_koa);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var n = parseInt(process.env.MW || '1', 10);
const app = new _koa2.default();

// number of middleware
let n = parseInt(process.env.MW || '1', 10);
console.log(' %s async middleware', n);

while (n--) {
app.use((() => {
var ref = _asyncToGenerator(function* (ctx, next) {
yield next();
});

return function (_x, _x2) {
return ref.apply(this, arguments);
};
})());
app.use(async (ctx, next) => {
await next();
});
}

var body = new Buffer('Hello World');

app.use((() => {
var ref = _asyncToGenerator(function* (ctx, next) {
yield next();
ctx.body = body;
});
const body = new Buffer('Hello World');

return function (_x3, _x4) {
return ref.apply(this, arguments);
};
})());
app.use(async (ctx, next) => {
await next();
ctx.body = body;
});

// var apprequire('./koa2-async.js')
app.listen(3333);

module.exports = app;
exports.default = app;
29 changes: 13 additions & 16 deletions koa2/koa2-async.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@

'use strict';

var http = require('http');
var koa = require('koa');
var app = new koa();
import http from 'http'
import Koa from 'koa'

const app = new Koa()

// number of middleware

var n = parseInt(process.env.MW || '1', 10);
console.log(' %s async middleware', n);
let n = parseInt(process.env.MW || '1', 10)
console.log(' %s async middleware', n)

while (n--) {
app.use(async (ctx, next) => {
await next();
});
await next()
})
}

var body = new Buffer('Hello World');
const body = new Buffer('Hello World')

app.use(async (ctx, next) => {
await next();
ctx.body = body;
});
await next()
ctx.body = body
})


// var apprequire('./koa2-async.js')
app.listen(3333);
app.listen(3333)

module.exports = app
export default app
6 changes: 1 addition & 5 deletions koa2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"devDependencies": {
"babel-cli": "^6.7.5",
"babel-core": "^6.7.5",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-transform-es2015-modules-commonjs": "^6.7.4",
"babel-polyfill": "^6.1.4",
"babel-preset-es2015-node5": "^1.2.0",
"babel-preset-stage-3": "^6.5.0"
"babel-preset-es2017-node7": "^0.3.0"
}
}
94 changes: 47 additions & 47 deletions logs/wrk_result.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
"port": "3333",
"threads": "8",
"connections": "50",
"latency_avg": "10.72",
"latency_stdev": "3.40",
"latency_max": "51.43",
"latency_precent": "93.00%",
"req_per_second_avg": "569.64",
"req_per_second_stdev": "107.73",
"req_per_second_max": "770.00 ",
"req_per_second_precent": "87.50%",
"requests_count": "13641",
"latency_avg": "11.02",
"latency_stdev": "5.67",
"latency_max": "54.13",
"latency_precent": "87.75%",
"req_per_second_avg": "568.74",
"req_per_second_stdev": "126.03",
"req_per_second_max": "740.00 ",
"req_per_second_precent": "77.92%",
"requests_count": "13617",
"requests_seconds": "3.01s",
"requests_read": "2.73MB",
"requests_per_sec": "4526.00",
"requests_per_sec": "4522.65",
"transfer_per_sec": "0.91M"
},
"koa1.js": {
Expand All @@ -25,58 +25,58 @@
"port": "3333",
"threads": "8",
"connections": "50",
"latency_avg": "10.04",
"latency_stdev": "3.48",
"latency_max": "42.47",
"latency_precent": "89.97%",
"req_per_second_avg": "607.86",
"req_per_second_stdev": "188.15",
"req_per_second_max": "2.23k ",
"req_per_second_precent": "92.56%",
"requests_count": "14664",
"latency_avg": "10.96",
"latency_stdev": "5.30",
"latency_max": "54.11",
"latency_precent": "85.40%",
"req_per_second_avg": "564.54",
"req_per_second_stdev": "170.20",
"req_per_second_max": "1.62k ",
"req_per_second_precent": "90.95%",
"requests_count": "13669",
"requests_seconds": "3.10s",
"requests_read": "2.11MB",
"requests_per_sec": "4723.93",
"transfer_per_sec": "696.60K"
"requests_read": "1.97MB",
"requests_per_sec": "4405.32",
"transfer_per_sec": "649.61K"
},
"koa2-async-compile.js": {
"time": "3",
"host": "localhost",
"port": "3333",
"threads": "8",
"connections": "50",
"latency_avg": "22.57",
"latency_stdev": "5.68",
"latency_max": "73.34",
"latency_precent": "94.58%",
"req_per_second_avg": "268.37",
"req_per_second_stdev": "48.76",
"req_per_second_max": "333.00 ",
"req_per_second_precent": "90.83%",
"requests_count": "6447",
"requests_seconds": "3.03s",
"requests_read": "0.93MB",
"requests_per_sec": "2129.67",
"transfer_per_sec": "314.04K"
"latency_avg": "16.74",
"latency_stdev": "6.92",
"latency_max": "62.26",
"latency_precent": "88.88%",
"req_per_second_avg": "366.57",
"req_per_second_stdev": "74.74",
"req_per_second_max": "484.00 ",
"req_per_second_precent": "80.83%",
"requests_count": "8779",
"requests_seconds": "3.01s",
"requests_read": "1.26MB",
"requests_per_sec": "2914.67",
"transfer_per_sec": "429.80K"
},
"koa2.js": {
"time": "3",
"host": "localhost",
"port": "3333",
"threads": "8",
"connections": "50",
"latency_avg": "8.85",
"latency_stdev": "2.94",
"latency_max": "42.26",
"latency_precent": "88.21%",
"req_per_second_avg": "688.38",
"req_per_second_stdev": "213.02",
"req_per_second_max": "2.71k ",
"req_per_second_precent": "92.15%",
"requests_count": "16609",
"latency_avg": "7.07",
"latency_stdev": "4.01",
"latency_max": "48.51",
"latency_precent": "88.19%",
"req_per_second_avg": "0.90k",
"req_per_second_stdev": "250.80",
"req_per_second_max": "1.99k ",
"req_per_second_precent": "88.52%",
"requests_count": "21852",
"requests_seconds": "3.10s",
"requests_read": "2.39MB",
"requests_per_sec": "5353.28",
"transfer_per_sec": "789.40K"
"requests_read": "3.15MB",
"requests_per_sec": "7042.91",
"transfer_per_sec": "1.01M"
}
}
82 changes: 82 additions & 0 deletions logs/wrk_result04-20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"express.js": {
"time": "3",
"host": "localhost",
"port": "3333",
"threads": "8",
"connections": "50",
"latency_avg": "10.72",
"latency_stdev": "3.40",
"latency_max": "51.43",
"latency_precent": "93.00%",
"req_per_second_avg": "569.64",
"req_per_second_stdev": "107.73",
"req_per_second_max": "770.00 ",
"req_per_second_precent": "87.50%",
"requests_count": "13641",
"requests_seconds": "3.01s",
"requests_read": "2.73MB",
"requests_per_sec": "4526.00",
"transfer_per_sec": "0.91M"
},
"koa1.js": {
"time": "3",
"host": "localhost",
"port": "3333",
"threads": "8",
"connections": "50",
"latency_avg": "10.04",
"latency_stdev": "3.48",
"latency_max": "42.47",
"latency_precent": "89.97%",
"req_per_second_avg": "607.86",
"req_per_second_stdev": "188.15",
"req_per_second_max": "2.23k ",
"req_per_second_precent": "92.56%",
"requests_count": "14664",
"requests_seconds": "3.10s",
"requests_read": "2.11MB",
"requests_per_sec": "4723.93",
"transfer_per_sec": "696.60K"
},
"koa2-async-compile.js": {
"time": "3",
"host": "localhost",
"port": "3333",
"threads": "8",
"connections": "50",
"latency_avg": "22.57",
"latency_stdev": "5.68",
"latency_max": "73.34",
"latency_precent": "94.58%",
"req_per_second_avg": "268.37",
"req_per_second_stdev": "48.76",
"req_per_second_max": "333.00 ",
"req_per_second_precent": "90.83%",
"requests_count": "6447",
"requests_seconds": "3.03s",
"requests_read": "0.93MB",
"requests_per_sec": "2129.67",
"transfer_per_sec": "314.04K"
},
"koa2.js": {
"time": "3",
"host": "localhost",
"port": "3333",
"threads": "8",
"connections": "50",
"latency_avg": "8.85",
"latency_stdev": "2.94",
"latency_max": "42.26",
"latency_precent": "88.21%",
"req_per_second_avg": "688.38",
"req_per_second_stdev": "213.02",
"req_per_second_max": "2.71k ",
"req_per_second_precent": "92.15%",
"requests_count": "16609",
"requests_seconds": "3.10s",
"requests_read": "2.39MB",
"requests_per_sec": "5353.28",
"transfer_per_sec": "789.40K"
}
}
2 changes: 1 addition & 1 deletion run
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

echo
MW=$1 node $2 &
MW=$1 node --harmony $2 &
pid=$!

sleep 2
Expand Down
2 changes: 1 addition & 1 deletion run2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

echo
MW=$1 node $2 &
MW=$1 node --harmony $2 &
pid=$!

sleep 2
Expand Down