Skip to content

Instantly share code, notes, and snippets.

Created May 8, 2014 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6a895ca27c0ca98aa0df to your computer and use it in GitHub Desktop.
Save anonymous/6a895ca27c0ca98aa0df to your computer and use it in GitHub Desktop.
simple benchmark
"""
>>> time python2.7 ./filename.py > /dev/null
real 0m17.911s
user 0m17.059s
sys 0m0.834s
>>> time pypy ./filename.py > /dev/null # pypy2.2.1 gevent 1.1.0-dev
real 0m14.118s
user 0m9.993s
sys 0m0.787s
"""
from gevent.pool import Pool
SIZE = 655350
pool = Pool(SIZE)
def incr(n):
print n+1
for i in xrange(SIZE):
pool.wait_available()
pool.spawn(incr, i)
pool.join()
package main
/*
>>> go build filename.go
>>> time GOMAXPROCS=1 ./filename > /dev/null
real 0m1.083s
user 0m0.834s
sys 0m0.255s
*/
import (
"fmt"
"sync"
)
const (
SIZE = 655350
)
func incr(num int) {
fmt.Println(num+1)
}
func main(){
var wg sync.WaitGroup
defer wg.Wait()
wg.Add(SIZE)
for i:=0; i<SIZE; i++ {
go func(num int){
defer wg.Done()
incr(num)
}(i)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment