Created
February 27, 2013 08:31
-
-
Save jdpaton/5046307 to your computer and use it in GitHub Desktop.
use res.write(buf) instead: http://techblog.safaribooksonline.com/2013/02/22/go-as-an-alternative-to-node-js-for-very-fast-servers/
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
± for i in {1..10}; do ./wrk http://localhost:8000 -c 100 | grep Requests | awk '{print $2}';done | awk '{s+=$1} END {print s}' | |
5329.22 | |
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
package main | |
import "net/http" | |
func main() { | |
bytes := make([]byte, 1024*1024) | |
for i := 0; i < len(bytes); i++ { | |
bytes[i] = 100 | |
} | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
w.Write(bytes) | |
}) | |
http.ListenAndServe(":8000", nil) | |
} |
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
http = require('http') | |
n = 1024*1024; | |
b = new Buffer(n); | |
for (var i = 0; i < n; i++) b[i] = 100; | |
http.createServer(function (req, res) { | |
res.writeHead(200); | |
res.write(b); | |
res.end(); | |
}).listen(8000); |
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
± for i in {1..10}; do ./wrk http://localhost:8000 -c 100 | grep Requests | awk '{print $2}';done | awk '{s+=$1} END {print s}' | |
9184.36 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment