Last active
November 8, 2015 09:17
-
-
Save philiptzou/8db4b05aa6d03cb7691d to your computer and use it in GitHub Desktop.
Node CGI vs. HTTP server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.stdout.write("Hello world!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"); | |
var server = http.createServer(function(request, response) { | |
response.writeHead(200, {"Content-Type": "text/plain"}); | |
response.write("Hello world!"); | |
response.end(); | |
}); | |
server.listen(7777); | |
console.log("Server is listening"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
import requests | |
print 'CGI: %.4fs' % timeit.timeit("subprocess.check_output(['node', 'cgi.js'])", | |
'import subprocess', number=100) | |
print 'HTTP: %.4fs' % timeit.timeit("requests.get('http://localhost:7777/').content", | |
"import requests", number=100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run "node http.js" in another console | |
python2.7 profile.py | |
CGI: 3.2942s | |
HTTP: 0.1447s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment