You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
433 B

package starmap
import (
"fmt"
"sync/atomic"
"testing"
"time"
)
func Test_Circle_Speed(t *testing.T) {
buf := StarStack{}
count := uint64(0)
for i := 1; i <= 10; i++ {
go func() {
for {
buf.Push('a')
}
}()
}
for i := 1; i <= 10; i++ {
go func() {
for {
_, err := buf.Pop()
if err == nil {
atomic.AddUint64(&count, 1)
}
}
}()
}
time.Sleep(time.Second * 10)
fmt.Println(count)
}