Mercurial > spidermonkey-playground
diff memory_profiler_server.js @ 67:a98e6a1144a9
Added some basic help info to the memory profiling server.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Thu, 25 Jun 2009 12:20:43 -0700 |
parents | 4910bc49a182 |
children | b87b6ebb6e86 |
line wrap: on
line diff
--- a/memory_profiler_server.js Thu Jun 25 12:13:22 2009 -0700 +++ b/memory_profiler_server.js Thu Jun 25 12:20:43 2009 -0700 @@ -3,9 +3,19 @@ var socket = new ServerSocket(); +var IP = "127.0.0.1"; var PORT = 8080; +var BASE_URL = "http://" + IP + ":" + PORT; +var HELP = [ + "REST API methods available:", + "", + " /gc-roots JSON array of GC root object IDs.", + " /objects/{ID} JSON metadata about the given object ID.", + " /stop Stops the server."]; -socket.bind("127.0.0.1", PORT); +HELP = HELP.join("\r\n"); + +socket.bind(IP, PORT); socket.listen(); var NEWLINE = "\r\n"; @@ -23,7 +33,8 @@ } } -print("Waiting for requests on port " + PORT + "."); +print("Waiting for requests at " + BASE_URL + ".\n"); +print(HELP); function processRequest(socket) { var conn = socket.accept(); @@ -45,6 +56,9 @@ // but Firefox doesn't let us browse a webserver this way, which is // annoying, so we're just leaving it at text/plain for now. + if (path == "/") + toSend = HELP; + if (path == "/gc-roots") toSend = JSON.stringify(getGCRoots());