Skip to content

Commit

Permalink
Clean up tests (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
puzpuzpuz authored Aug 30, 2021
1 parent 1ad5cea commit 1fd9408
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
30 changes: 16 additions & 14 deletions map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,20 @@ func TestMapResize_CounterLenLimit(t *testing.T) {
}

func parallelSeqStorer(t *testing.T, m *Map, storeEach, numIters, numEntries int, cdone chan bool) {
for j := 0; j < numEntries; j++ {
if storeEach == 0 || j%storeEach == 0 {
m.Store(strconv.Itoa(j), j)
// Due to atomic snapshots we must see a "<j>"/j pair.
v, ok := m.Load(strconv.Itoa(j))
if !ok {
t.Errorf("value was not found for %d", j)
break
}
if vi, ok := v.(int); !ok || vi != j {
t.Errorf("value was not expected for %d: %d", j, vi)
break
for i := 0; i < numIters; i++ {
for j := 0; j < numEntries; j++ {
if storeEach == 0 || j%storeEach == 0 {
m.Store(strconv.Itoa(j), j)
// Due to atomic snapshots we must see a "<j>"/j pair.
v, ok := m.Load(strconv.Itoa(j))
if !ok {
t.Errorf("value was not found for %d", j)
break
}
if vi, ok := v.(int); !ok || vi != j {
t.Errorf("value was not expected for %d: %d", j, vi)
break
}
}
}
}
Expand All @@ -332,8 +334,8 @@ func parallelSeqStorer(t *testing.T, m *Map, storeEach, numIters, numEntries int

func TestMapParallelStores(t *testing.T) {
const numStorers = 4
const numIters = 10_000_000
const numEntries = 1000
const numIters = 10_000
const numEntries = 100
m := NewMap()
cdone := make(chan bool)
for i := 0; i < numStorers; i++ {
Expand Down
6 changes: 3 additions & 3 deletions mpmcqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ func TestQueueNonBlockingCalls(t *testing.T) {
if testing.Short() {
n = 1
}
hammerQueueNonBlockingCalls(t, 1, 10*n, n)
hammerQueueNonBlockingCalls(t, 4, 100*n, 2*n)
hammerQueueNonBlockingCalls(t, 8, 1000*n, 4*n)
hammerQueueNonBlockingCalls(t, 1, n, n)
hammerQueueNonBlockingCalls(t, 2, 10*n, 2*n)
hammerQueueNonBlockingCalls(t, 4, 100*n, 4*n)
}

func benchmarkQueueProdCons(b *testing.B, queueSize, localWork int) {
Expand Down

0 comments on commit 1fd9408

Please sign in to comment.