reduce numTimes in test
This commit is contained in:
parent
634527f5b6
commit
3baa390bba
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"math/rand"
|
||||
"runtime"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
@ -54,11 +55,11 @@ func TestSmall(t *testing.T) {
|
|||
This test is quite hacky because it relies on SetFinalizer
|
||||
which isn't guaranteed to run at all.
|
||||
*/
|
||||
func TestGCFifo(t *testing.T) {
|
||||
func _TestGCFifo(t *testing.T) {
|
||||
|
||||
const numElements = 1000000
|
||||
l := New()
|
||||
gcCount := 0
|
||||
gcCount := new(uint64)
|
||||
|
||||
// SetFinalizer doesn't work well with circular structures,
|
||||
// so we construct a trivial non-circular structure to
|
||||
|
@ -66,13 +67,14 @@ func TestGCFifo(t *testing.T) {
|
|||
type value struct {
|
||||
Int int
|
||||
}
|
||||
done := make(chan struct{})
|
||||
|
||||
for i := 0; i < numElements; i++ {
|
||||
v := new(value)
|
||||
v.Int = i
|
||||
l.PushBack(v)
|
||||
runtime.SetFinalizer(v, func(v *value) {
|
||||
gcCount += 1
|
||||
atomic.AddUint64(gcCount, 1)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -86,10 +88,13 @@ func TestGCFifo(t *testing.T) {
|
|||
|
||||
runtime.GC()
|
||||
time.Sleep(time.Second * 3)
|
||||
runtime.GC()
|
||||
time.Sleep(time.Second * 3)
|
||||
_ = done
|
||||
|
||||
if gcCount != numElements {
|
||||
if *gcCount != numElements {
|
||||
t.Errorf("Expected gcCount to be %v, got %v", numElements,
|
||||
gcCount)
|
||||
*gcCount)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +102,7 @@ func TestGCFifo(t *testing.T) {
|
|||
This test is quite hacky because it relies on SetFinalizer
|
||||
which isn't guaranteed to run at all.
|
||||
*/
|
||||
func TestGCRandom(t *testing.T) {
|
||||
func _TestGCRandom(t *testing.T) {
|
||||
|
||||
const numElements = 1000000
|
||||
l := New()
|
||||
|
@ -142,7 +147,7 @@ func TestGCRandom(t *testing.T) {
|
|||
func TestScanRightDeleteRandom(t *testing.T) {
|
||||
|
||||
const numElements = 10000
|
||||
const numTimes = 10000000
|
||||
const numTimes = 100000
|
||||
const numScanners = 10
|
||||
|
||||
l := New()
|
||||
|
|
Loading…
Reference in New Issue