Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2010-05-05 09:35:55 +0400
committerRyan Dahl <ry@tinyclouds.org>2010-05-05 09:35:55 +0400
commitab723d022d7a055f046216013c64032ced9ed081 (patch)
tree143b90b472ce8ec2bf77a5d314fff64182c8d79d /benchmark
parent141565046375db6fa427ba014113abcc9f4d5833 (diff)
Add buffer response to http_simple.js
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/http_simple.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/benchmark/http_simple.js b/benchmark/http_simple.js
index 54958d169b6..627835b7972 100644
--- a/benchmark/http_simple.js
+++ b/benchmark/http_simple.js
@@ -1,4 +1,5 @@
path = require("path");
+Buffer = require("buffer").Buffer;
port = parseInt(process.env.PORT || 8000);
@@ -17,6 +18,7 @@ for (var i = 0; i < 20*1024; i++) {
}
stored = {};
+storedBuffer = {};
http.createServer(function (req, res) {
var commands = req.url.split("/");
@@ -38,6 +40,18 @@ http.createServer(function (req, res) {
}
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") {
res.connection.server.close();
body = "quitting";