Browse Source

Add buffer response to http_simple.js

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
ab723d022d
  1. 14
      benchmark/http_simple.js

14
benchmark/http_simple.js

@ -1,4 +1,5 @@
path = require("path"); path = require("path");
Buffer = require("buffer").Buffer;
port = parseInt(process.env.PORT || 8000); port = parseInt(process.env.PORT || 8000);
@ -17,6 +18,7 @@ for (var i = 0; i < 20*1024; i++) {
} }
stored = {}; stored = {};
storedBuffer = {};
http.createServer(function (req, res) { http.createServer(function (req, res) {
var commands = req.url.split("/"); var commands = req.url.split("/");
@ -38,6 +40,18 @@ http.createServer(function (req, res) {
} }
body = stored[n]; body = stored[n];
} else if (command == "buffer") {
var n = parseInt(arg, 10)
if (n <= 0) throw new Error("bytes called with n <= 0");
if (storedBuffer[n] === undefined) {
puts("create storedBuffer[n]");
storedBuffer[n] = new Buffer(n);
for (var i = 0; i < n; i++) {
storedBuffer[n][i] = "C".charCodeAt(0);
}
}
body = storedBuffer[n];
} else if (command == "quit") { } else if (command == "quit") {
res.connection.server.close(); res.connection.server.close();
body = "quitting"; body = "quitting";

Loading…
Cancel
Save