5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-23 02:01:36 +00:00
yggdrasil-go/misc/tests/goroutine-test.go

23 lines
367 B
Go
Raw Normal View History

2017-12-29 04:16:20 +00:00
package main
import "sync"
import "time"
import "fmt"
2018-01-04 22:37:51 +00:00
func main() {
const reqs = 1000000
var wg sync.WaitGroup
start := time.Now()
for idx := 0; idx < reqs; idx++ {
wg.Add(1)
go func() { wg.Done() }()
}
wg.Wait()
stop := time.Now()
timed := stop.Sub(start)
fmt.Printf("%d goroutines in %s (%f per second)\n",
reqs,
timed,
reqs/timed.Seconds())
2017-12-29 04:16:20 +00:00
}