This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap-benchmarks".
The branch, master has been updated
via 8f04b955b083bfcee9af102f44fda0e7c611bf69 (commit)
from f71c34b1171c8a70fe6b1e3027b1f75ff6483d93 (commit)
Summary of changes:
node-bench/pong.js | 47 ++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 42 insertions(+), 5 deletions(-)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8f04b955b083bfcee9af102f44fda0e7c611bf69
Author: Mark Wotton <[email protected]>
Date: Sun Aug 8 14:24:27 2010 +1000
add echo and fileserver for node benchmark
diff --git a/node-bench/pong.js b/node-bench/pong.js
index 5ae7e07..674efdc 100644
--- a/node-bench/pong.js
+++ b/node-bench/pong.js
@@ -1,6 +1,43 @@
-var http = require('http');
-http.createServer(function (req, res) {
- res.writeHead(200, {'Content-Type': 'text/plain'});
- res.end('PONG');
+var http = require("http"),
+url = require("url"),
+path = require("path"),
+fs = require("fs"),
+sys = require('sys');
+
+
+
+http.createServer(function (request, response) {
+
+ var uri = url.parse(request.url).pathname;
+
+ if(uri=='/pong') {
+ response.writeHead(200, {'Content-Type': 'text/plain'});
+ response.end('PONG');
+ } else if ((match = uri.match(/^\/echo\/(.*)$/)) != null) {
+ response.writeHead(200, {'Content-Type': 'text/plain'});
+ response.end(match[1]);
+ } else {
+ var filename = path.join(process.cwd(), uri);
+ path.exists(filename, function(exists) {
+ if(!exists) {
+ response.writeHead(404, {"Content-Type": "text/plain"});
+ response.end("404 Not Found\n");
+ return;
+ }
+
+ fs.readFile(filename, "binary", function(err, file) {
+ if(err) {
+ response.writeHead(500, {"Content-Type": "text/plain"});
+ response.end(err + "\n");
+ return;
+ }
+
+ response.writeHead(200);
+ response.write(file, "binary");
+ response.end();
+ });
+ });
+ }
}).listen(8124, "localhost");
-console.log('Server running at http://127.0.0.1:8124/');
+
+sys.puts('Server running at http://127.0.0.1:8124/');
-----------------------------------------------------------------------
hooks/post-receive
--
snap-benchmarks
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap