Created
February 20, 2014 08:22
-
-
Save wari/9109081 to your computer and use it in GitHub Desktop.
My silly tests with Go and Nodejs with RaspberryPi RevB 512MB, all these due to the silly discussion in golang-nuts - https://groups.google.com/forum/#!topic/golang-nuts/zeLMYnjO_JA[1-25-false] TLDR: Even with extra work golang is faster :P
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
pi@waripi ~ $ ab -n 1000 -n 10000 http://192.168.1.244:8000/ | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 192.168.1.244 (be patient) | |
Completed 1000 requests | |
Completed 2000 requests | |
Completed 3000 requests | |
Completed 4000 requests | |
Completed 5000 requests | |
Completed 6000 requests | |
Completed 7000 requests | |
Completed 8000 requests | |
Completed 9000 requests | |
Completed 10000 requests | |
Finished 10000 requests | |
Server Software: | |
Server Hostname: 192.168.1.244 | |
Server Port: 8000 | |
Document Path: / | |
Document Length: 20 bytes | |
Concurrency Level: 1 | |
Time taken for tests: 46.718 seconds | |
Complete requests: 10000 | |
Failed requests: 0 | |
Write errors: 0 | |
Total transferred: 1370000 bytes | |
HTML transferred: 200000 bytes | |
Requests per second: 214.05 [#/sec] (mean) | |
Time per request: 4.672 [ms] (mean) | |
Time per request: 4.672 [ms] (mean, across all concurrent requests) | |
Transfer rate: 28.64 [Kbytes/sec] received | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 0 1 0.1 1 3 | |
Processing: 2 4 1.8 4 75 | |
Waiting: 0 2 1.6 2 74 | |
Total: 3 4 1.8 5 75 | |
Percentage of the requests served within a certain time (ms) | |
50% 5 | |
66% 5 | |
75% 5 | |
80% 5 | |
90% 5 | |
95% 6 | |
98% 7 | |
99% 8 | |
100% 75 (longest request) |
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 ( | |
"fmt" | |
"net/http" | |
) | |
func visitor_counter() chan int { | |
i := 1 | |
c := make(chan int) | |
go func() { | |
for { | |
c <- i | |
i++ | |
} | |
}() | |
return c | |
} | |
func webHandler(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hello World") | |
} | |
func main() { | |
c := visitor_counter() | |
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hello visitor #%d", <-c) | |
}) | |
http.HandleFunc("/plain", webHandler) | |
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
pi@waripi ~ $ ab -n 1000 -n 10000 http://192.168.1.244:1337/ | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 192.168.1.244 (be patient) | |
Completed 1000 requests | |
Completed 2000 requests | |
Completed 3000 requests | |
Completed 4000 requests | |
Completed 5000 requests | |
Completed 6000 requests | |
Completed 7000 requests | |
Completed 8000 requests | |
Completed 9000 requests | |
Completed 10000 requests | |
Finished 10000 requests | |
Server Software: | |
Server Hostname: 192.168.1.244 | |
Server Port: 1337 | |
Document Path: / | |
Document Length: 12 bytes | |
Concurrency Level: 1 | |
Time taken for tests: 61.900 seconds | |
Complete requests: 10000 | |
Failed requests: 0 | |
Write errors: 0 | |
Total transferred: 760000 bytes | |
HTML transferred: 120000 bytes | |
Requests per second: 161.55 [#/sec] (mean) | |
Time per request: 6.190 [ms] (mean) | |
Time per request: 6.190 [ms] (mean, across all concurrent requests) | |
Transfer rate: 11.99 [Kbytes/sec] received | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 0 1 0.1 1 3 | |
Processing: 4 5 2.2 5 113 | |
Waiting: 0 4 2.1 4 110 | |
Total: 5 6 2.2 6 114 | |
Percentage of the requests served within a certain time (ms) | |
50% 6 | |
66% 6 | |
75% 6 | |
80% 6 | |
90% 6 | |
95% 6 | |
98% 7 | |
99% 12 | |
100% 114 (longest request) |
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'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('Hello World\n'); | |
}).listen(1337, '0.0.0.0'); | |
console.log('Server running at http://0.0.0.0:1337/'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment