mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 17:15:56 +00:00
Lower scale of some random-value tests
The random-value tests can be pathological, and in particular, the test of arbitrarily-spaced values is in effect O(N^2), and with race testing on, that test *alone* can take ten minutes to run, but it's not really all that exciting. We just reduce a bunch of values and/or test fewer things for these, which doesn't significantly alter coverage, but reduces test runtime on my laptop with `-race` from 21 minutes to a bit under 5.
This commit is contained in:
parent
0a17b3713c
commit
55ff03a2d6
2 changed files with 13 additions and 10 deletions
|
|
@ -15,6 +15,7 @@
|
|||
package roaring
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
|
@ -110,13 +111,15 @@ func TestUnionSlice(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMaxInSlice(t *testing.T) {
|
||||
// arbitrary, we just want to get the same values every time
|
||||
r := rand.New(rand.NewSource(23))
|
||||
a := []uint64{1, 4, 9, 5, 24, 13}
|
||||
v := maxInSlice(a)
|
||||
if uint64(24) != v {
|
||||
t.Fatalf("expected %v, but got %v", uint64(24), v)
|
||||
}
|
||||
|
||||
for i := uint64(1000); i <= uint64(100000); i++ {
|
||||
for i := uint64(1000); i <= uint64(100000); i += uint64(r.Intn(35)) + 1 {
|
||||
a = append(a, i)
|
||||
if v = maxInSlice(a); v != i {
|
||||
t.Fatalf("expected %v, but got %v", i, v)
|
||||
|
|
|
|||
|
|
@ -866,7 +866,7 @@ func TestBitmap_UnionInPlaceProp(t *testing.T) {
|
|||
seed = time.Now().UnixNano()
|
||||
source = rand.NewSource(seed)
|
||||
rng = rand.New(source)
|
||||
numTests = 100
|
||||
numTests = 20
|
||||
maxNumIntsPerBatch = 100
|
||||
maxNumBatches = 100
|
||||
maxRangePercent = 2
|
||||
|
|
@ -1425,10 +1425,10 @@ func TestBitmap_Shift(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestBitmap_Quick_Array1(t *testing.T) { testBitmapQuick(t, 1000, 1000, 2000) }
|
||||
func TestBitmap_Quick_Array2(t *testing.T) { testBitmapQuick(t, 10000, 0, 1000) }
|
||||
func TestBitmap_Quick_Bitmap1(t *testing.T) { testBitmapQuick(t, 10000, 0, 10000) }
|
||||
func TestBitmap_Quick_Bitmap2(t *testing.T) { testBitmapQuick(t, 10000, 10000, 20000) }
|
||||
func TestBitmap_Quick_LargeValue(t *testing.T) { testBitmapQuick(t, 10000, 0, math.MaxInt64) }
|
||||
func TestBitmap_Quick_Array2(t *testing.T) { testBitmapQuick(t, 1000, 0, 1000) }
|
||||
func TestBitmap_Quick_Bitmap1(t *testing.T) { testBitmapQuick(t, 1000, 0, 10000) }
|
||||
func TestBitmap_Quick_Bitmap2(t *testing.T) { testBitmapQuick(t, 1000, 10000, 20000) }
|
||||
func TestBitmap_Quick_LargeValue(t *testing.T) { testBitmapQuick(t, 1000, 0, math.MaxInt64) }
|
||||
|
||||
// Ensure a bitmap can perform basic operations on randomly generated values.
|
||||
func testBitmapQuick(t *testing.T, n int, min, max uint64) {
|
||||
|
|
@ -1504,20 +1504,20 @@ func TestBitmap_Marshal_Quick_Array1(t *testing.T) {
|
|||
testBitmapMarshalQuick(t, 1000, 1000, 2000, false)
|
||||
}
|
||||
func TestBitmap_Marshal_Quick_Array2(t *testing.T) {
|
||||
testBitmapMarshalQuick(t, 10000, 0, 1000, false)
|
||||
testBitmapMarshalQuick(t, 1000, 0, 1000, false)
|
||||
}
|
||||
func TestBitmap_Marshal_Quick_Bitmap1(t *testing.T) {
|
||||
testBitmapMarshalQuick(t, 10000, 0, 10000, false)
|
||||
testBitmapMarshalQuick(t, 1000, 0, 10000, false)
|
||||
}
|
||||
func TestBitmap_Marshal_Quick_Bitmap2(t *testing.T) {
|
||||
testBitmapMarshalQuick(t, 10000, 10000, 20000, false)
|
||||
testBitmapMarshalQuick(t, 1000, 10000, 20000, false)
|
||||
}
|
||||
func TestBitmap_Marshal_Quick_LargeValue(t *testing.T) {
|
||||
testBitmapMarshalQuick(t, 100, 0, math.MaxInt64, false)
|
||||
}
|
||||
|
||||
func TestBitmap_Marshal_Quick_Bitmap_Sorted(t *testing.T) {
|
||||
testBitmapMarshalQuick(t, 10000, 0, 10000, true)
|
||||
testBitmapMarshalQuick(t, 1000, 0, 10000, true)
|
||||
}
|
||||
|
||||
// TODO update for RLE
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue