mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-06-17 06:35:07 +03:00
Run gofmt -s -w .
This commit is contained in:
parent
ae7b07ae6a
commit
b3ebe76b59
45 changed files with 5037 additions and 4288 deletions
|
@ -5,32 +5,32 @@ import "fmt"
|
|||
import "sync"
|
||||
|
||||
func main() {
|
||||
fmt.Println("Testing speed of recv+send loop")
|
||||
const count = 10000000
|
||||
c := make(chan []byte, 1)
|
||||
c<-[]byte{}
|
||||
var wg sync.WaitGroup
|
||||
worker := func () {
|
||||
for idx := 0 ; idx < count ; idx++ {
|
||||
p := <-c
|
||||
select {
|
||||
case c<-p:
|
||||
default:
|
||||
}
|
||||
}
|
||||
wg.Done()
|
||||
}
|
||||
nIter := 0
|
||||
start := time.Now()
|
||||
for idx := 0 ; idx < 1 ; idx++ {
|
||||
go worker()
|
||||
nIter += count
|
||||
wg.Add(1)
|
||||
}
|
||||
wg.Wait()
|
||||
stop := time.Now()
|
||||
timed := stop.Sub(start)
|
||||
fmt.Printf("%d iterations in %s\n", nIter, timed)
|
||||
fmt.Printf("%f iterations per second\n", float64(nIter)/timed.Seconds())
|
||||
fmt.Printf("%s per iteration\n", timed/time.Duration(nIter))
|
||||
fmt.Println("Testing speed of recv+send loop")
|
||||
const count = 10000000
|
||||
c := make(chan []byte, 1)
|
||||
c <- []byte{}
|
||||
var wg sync.WaitGroup
|
||||
worker := func() {
|
||||
for idx := 0; idx < count; idx++ {
|
||||
p := <-c
|
||||
select {
|
||||
case c <- p:
|
||||
default:
|
||||
}
|
||||
}
|
||||
wg.Done()
|
||||
}
|
||||
nIter := 0
|
||||
start := time.Now()
|
||||
for idx := 0; idx < 1; idx++ {
|
||||
go worker()
|
||||
nIter += count
|
||||
wg.Add(1)
|
||||
}
|
||||
wg.Wait()
|
||||
stop := time.Now()
|
||||
timed := stop.Sub(start)
|
||||
fmt.Printf("%d iterations in %s\n", nIter, timed)
|
||||
fmt.Printf("%f iterations per second\n", float64(nIter)/timed.Seconds())
|
||||
fmt.Printf("%s per iteration\n", timed/time.Duration(nIter))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue