Skip to content

Instantly share code, notes, and snippets.

@samuell
Last active December 18, 2015 18:59
Show Gist options
  • Select an option

  • Save samuell/5829878 to your computer and use it in GitHub Desktop.

Select an option

Save samuell/5829878 to your computer and use it in GitHub Desktop.
package main
import (
)
func main() {
for i := 0; i<1000000; i++ {
c := create_empty_goroutine()
<-c
}
}
func create_empty_goroutine() chan int {
c := make(chan int)
go func() { c <- 1 }()
return c
}
@samuell

samuell commented Jun 21, 2013

Copy link
Copy Markdown
Author
[samuel gotest]$ for i in $(seq 1 1 4); do export GOMAXPROCS=$i; echo "Starting $i threads..."; time ./goroutinetest; done;
Starting 1 threads...

real    0m0.874s
user    0m0.852s
sys 0m0.052s
Starting 2 threads...

real    0m4.100s
user    0m4.992s
sys 0m2.300s
Starting 3 threads...

real    0m4.086s
user    0m5.196s
sys 0m2.536s
Starting 4 threads...

real    0m3.690s
user    0m4.824s
sys 0m2.064s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment