Golang on GAE is so fast!
I became a trusted tester for Google App Engine/Go.
So, I benchmarked this. And I compared GAE/Golang with GAE/Python.
I checked calculating time for make prime numbers(<10000).
result
times | Golang | Python |
---|---|---|
1st try | 49.2 | 807.3 |
2nd try | 49.7 | 833.0 |
3rd try | 49.0 | 830.6 |
4th try | 50.0 | 806.7 |
5th try | 49.2 | 782.2 |
average | 49.42 | 811.96 |
This values means MilliSecond.
You can understand that GAE is so fast.
I used this code.
Golang
package test4golang import ( "fmt" "http" "os" ) func init(){ http.HandleFunc("/",prime) } func prime(w http.ResponseWriter, r *http.Request) { startTimeS, startTimeM, _ := os.Time() for i:=1;i<10000;i++ { for j:=2; j<int(i/2); j++ { if i%j == 0 { break; } } } finishTimeS, finishTimeM, _ := os.Time() finishTime := finishTimeS*1e9 + finishTimeM startTime := startTimeS*1e9 + startTimeM fmt.Fprintf(w,"%d , %d<br> %d",startTime,finishTime,finishTime-startTime) return }
Python
import cgi from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from time import time class PrimeNumber(webapp.RequestHandler): def get(self): i=0 j=0 startTime = time() while i<10000: j = 2 while j<(i/2): if i%j == 0: break j +=1 i += 1 finishTime = time() self.response.out.write(finishTime - startTime) application = webapp.WSGIApplication([ ('/',PrimeNumber)],debug=True) def main(): run_wsgi_app(application) if __name__ == "__main__": main()
Corrected
14:58 June,11 | I made mistake in Python's result. I corrected it. |
---|