This file contains hidden or 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 core | |
import ( | |
"bytes" | |
"fmt" | |
"html/template" | |
"io/ioutil" | |
"net/http" | |
"os" | |
"path/filepath" |
This file contains hidden or 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
jordanorelli@yupa[0] ~: ab -n 10 -c 10 "http://127.0.0.1:8080/" | |
This is ApacheBench, Version 2.3 <$Revision: 1178079 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 127.0.0.1 (be patient).....done | |
Server Software: | |
Server Hostname: 127.0.0.1 |
This file contains hidden or 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
type idCache struct { | |
data map[string]*string | |
maxSize int | |
newest *string | |
oldest *string | |
} | |
func newIdCache(size int) *idCache { | |
return &idCache{ | |
data: make(map[string]*string, size), |
This file contains hidden or 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" | |
"runtime" | |
"time" | |
) | |
func main() { | |
// THIS is totally required; without it, you're blocking the CPU regardless |
This file contains hidden or 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" | |
"math/rand" | |
"time" | |
) | |
type Queue struct { | |
data []interface{} |
This file contains hidden or 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" | |
"math/rand" | |
"time" | |
) | |
func produce(c chan int) { | |
// loop indefinitely |
This file contains hidden or 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
from random import randint | |
import gevent | |
def mightfail(): | |
x = randint(1, 10) | |
print x | |
if x == 10: | |
raise ValueError("that's too big") | |
return x |
This file contains hidden or 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
from random import randint | |
import gevent | |
def mightfail(): | |
x = randint(1, 10) | |
if x == 10: | |
raise ValueError("that's too big") | |
return x | |
jobs = [gevent.spawn(mightfail) for x in xrange(50)] |
This file contains hidden or 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
from random import randint | |
from gevent.util import wrap_errors | |
import gevent | |
def mightfail(): | |
x = randint(1, 10) | |
if x == 10: | |
raise ValueError("that's too big") | |
return x |
This file contains hidden or 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
from random import randint | |
from gevent.util import wrap_errors | |
import gevent | |
def mightfail(): | |
x = randint(1, 10) | |
if x == 10: | |
raise ValueError("that's too big") | |
return x |