Permalink
Browse files

performance, refactor

  • Loading branch information...
1 parent 7adf4a3 commit 7297bf3f8f3e0b9500b94597731d13d4d8372306 @billywhizz committed Feb 19, 2011
Showing with 519 additions and 434 deletions.
  1. +11 −13 benchmark/speed-fcgi.js
  2. +1 −1 benchmark/speed-http.js
  3. +3 −3 examples/php-server.js
  4. +235 −192 lib/fastcgi.js
  5. +15 −15 package.json
  6. +5 −4 runbench.sh
  7. +238 −199 tests/test-parser.js
  8. +11 −7 tests/test.js
View
@@ -6,12 +6,13 @@ var buffers = [];
var bytes = 0;
var parser = new fastcgi.parser();
+var mode = process.ARGV[2];
-var log = fs.createReadStream(process.ARGV[2], {
+var log = fs.createReadStream("fastcgi." + mode, {
"flags": "r",
"encoding": null,
"mode": 0755,
- "bufferSize": process.ARGV[3]
+ "bufferSize": parseInt(process.ARGV[3]) * 1024
});
log.addListener("data", function(buff) {
@@ -27,19 +28,16 @@ log.addListener("end", function() {
console.log("total: " + rec);
});
-/*
-parser.onParam = function(name, value) {
-
-};
-
-parser.onHeader = function(header) {
-
-};
-*/
+var FCGI_END = fastcgi.constants.record.FCGI_END;
+var FCGI_STDIN = fastcgi.constants.record.FCGI_STDIN;
parser.onRecord = function(record) {
- //console.log(JSON.stringify(record));
- rec++;
+ if(((mode == "out") && (record.header.type == FCGI_END))) {
+ rec++;
+ }
+ else if(((mode == "in") && (record.header.type == FCGI_STDIN) && record.header.contentLength == 0)) {
+ rec++;
+ }
};
parser.onError = function(err) {
View
@@ -11,7 +11,7 @@ var log = fs.createReadStream(process.ARGV[2], {
"flags": "r",
"encoding": null,
"mode": 0755,
- "bufferSize": process.ARGV[3]
+ "bufferSize": parseInt(process.ARGV[3] * 1024)
});
log.addListener("data", function(buffer) {
View
@@ -17,7 +17,7 @@ You can then run this example to fire requests at the php server
You will need to change the SCRIPT_FILENAME param below to the full path of a script that is available to the php application
*/
var params = [
- ["SCRIPT_FILENAME", "/source/phpinfo.php"],
+ ["SCRIPT_FILENAME", "/usr/share/nginx/html/mediawiki/config/index.php"],
["QUERY_STRING", ""],
["REQUEST_METHOD", "GET"],
["CONTENT_TYPE", ""],
@@ -107,7 +107,7 @@ function client() {
connection.writer = new fastcgi.writer();
connection.parser = new fastcgi.parser();
connection.parser.onRecord = function(record) {
- //console.log(JSON.stringify(record, null, "\t"));
+ console.log(JSON.stringify(record, null, "\t"));
count++;
recordId = record.header.recordId;
};
@@ -137,7 +137,7 @@ function client() {
setTimeout(function() {
//console.log("reconnect");
//connection.connect("/tmp/nginx.sock");
- connection.connect(6000, "icms.owner.net");
+ //connection.connect(6000, "icms.owner.net");
}, 0);
});
Oops, something went wrong.

0 comments on commit 7297bf3

Please sign in to comment.