@@ -10,8 +10,9 @@ import (
10
10
11
11
func TestStressMemDB (t * testing.T ) {
12
12
simpleMemDBOperations (t , NewMemDB ())
13
- stressTestConcurrentUse (t , NewMemDB (), 1e5 , 20 )
14
- stressTestConcurrentUse (t , NewMemDB ().Subset ([]byte {10 , 11 , 12 , 13 }), 1e5 , 10 )
13
+ r := rand .New (rand .NewSource (rand .Int63 ()))
14
+ stressTestConcurrentUse (t , NewMemDB (), 1e5 , 20 , r )
15
+ stressTestConcurrentUse (t , NewMemDB ().Subset ([]byte {10 , 11 , 12 , 13 }), 1e5 , 10 , r )
15
16
}
16
17
17
18
func TestChanges (t * testing.T ) {
@@ -99,16 +100,16 @@ func simpleMemDBOperations(t *testing.T, db DB) {
99
100
common .FailIfErr (t , db .Delete ([]byte {1 , 2 , 3 , 4 }))
100
101
}
101
102
102
- func stressTestConcurrentUse (t * testing.T , db DB , numInserts int , numThreads int ) {
103
+ func stressTestConcurrentUse (t * testing.T , db DB , numInserts int , numThreads int , r * rand. Rand ) {
103
104
inputs := make ([][][2 ][]byte , 0 , numThreads )
104
105
dbs := make ([]DB , 0 , numThreads )
105
106
106
107
for i := 0 ; i < numThreads ; i += 1 {
107
108
dbs = append (dbs , db )
108
109
currentInputs := make ([][2 ][]byte , numInserts )
109
110
for i := 0 ; i < numInserts ; i += 1 {
110
- currentInputs [i ][0 ] = common .Uint64ToBytes (rand .Uint64 ())
111
- currentInputs [i ][1 ] = common .Uint64ToBytes (rand .Uint64 ())
111
+ currentInputs [i ][0 ] = common .Uint64ToBytes (r .Uint64 ())
112
+ currentInputs [i ][1 ] = common .Uint64ToBytes (r .Uint64 ())
112
113
}
113
114
inputs = append (inputs , currentInputs )
114
115
}
0 commit comments