You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
631 B
Go
43 lines
631 B
Go
3 years ago
|
package starnet
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
func Test_QueSpeed(t *testing.T) {
|
||
|
que := NewQueueWithCount(0)
|
||
|
stop := make(chan struct{}, 1)
|
||
|
que.RestoreDuration(time.Second * 10)
|
||
|
var count int64
|
||
|
go func() {
|
||
|
for {
|
||
|
select {
|
||
|
case <-stop:
|
||
|
//fmt.Println(count)
|
||
|
return
|
||
|
default:
|
||
|
}
|
||
|
_, err := que.RestoreOne()
|
||
|
if err == nil {
|
||
|
count++
|
||
|
}
|
||
|
}
|
||
|
}()
|
||
|
cp := 0
|
||
|
stoped := time.After(time.Second * 10)
|
||
|
data := que.BuildMessage([]byte("hello"))
|
||
|
for {
|
||
|
select {
|
||
|
case <-stoped:
|
||
|
fmt.Println(count, cp)
|
||
|
stop <- struct{}{}
|
||
|
return
|
||
|
default:
|
||
|
que.ParseMessage(data, "lala")
|
||
|
cp++
|
||
|
}
|
||
|
}
|
||
|
}
|