Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-ds-flatfs
Commits
51a1252c
Commit
51a1252c
authored
Jan 19, 2017
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use math/rand and increase tolerance on tests because poisson is a jerk
parent
1eb10548
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
+8
-10
convert_test.go
convert_test.go
+3
-4
flatfs_test.go
flatfs_test.go
+5
-6
No files found.
convert_test.go
View file @
51a1252c
...
...
@@ -4,15 +4,14 @@ import (
"bytes"
"encoding/hex"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
"testing"
"time"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-ds-flatfs"
//"gx/ipfs/QmRWDav6mzWseLWeYfVd5fvUKiVe9xNH29YfMF438fG364/go-datastore/query"
rand
"github.com/dustin/randbo"
)
func
TestMove
(
t
*
testing
.
T
)
{
...
...
@@ -197,7 +196,7 @@ func populateDatastore(t *testing.T, dir string) ([]datastore.Key, [][]byte) {
t
.
Fatalf
(
"Open fail: %v
\n
"
,
err
)
}
r
:=
rand
.
New
()
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
())
)
var
blocks
[][]
byte
var
keys
[]
datastore
.
Key
for
i
:=
0
;
i
<
256
;
i
++
{
...
...
flatfs_test.go
View file @
51a1252c
...
...
@@ -9,13 +9,12 @@ import (
"path/filepath"
"runtime"
"testing"
"time"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/query"
dstest
"github.com/ipfs/go-datastore/test"
"github.com/ipfs/go-ds-flatfs"
randbo
"github.com/dustin/randbo"
)
func
tempdir
(
t
testing
.
TB
)
(
path
string
,
cleanup
func
())
{
...
...
@@ -465,7 +464,7 @@ func TestNoCluster(t *testing.T) {
t
.
Fatalf
(
"New fail: %v
\n
"
,
err
)
}
r
:=
rand
bo
.
New
From
(
rand
.
NewSource
(
0
))
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()
))
N
:=
3200
// should be divisible by 32 so the math works out
for
i
:=
0
;
i
<
N
;
i
++
{
blk
:=
make
([]
byte
,
1000
)
...
...
@@ -483,7 +482,7 @@ func TestNoCluster(t *testing.T) {
t
.
Fatalf
(
"ReadDir fail: %v
\n
"
,
err
)
}
idealFilesPerDir
:=
float64
(
N
)
/
32.0
tolerance
:=
math
.
Floor
(
idealFilesPerDir
*
0.
2
0
)
tolerance
:=
math
.
Floor
(
idealFilesPerDir
*
0.
5
0
)
count
:=
0
for
_
,
dir
:=
range
dirs
{
if
dir
.
Name
()
==
flatfs
.
SHARDING_FN
||
dir
.
Name
()
==
flatfs
.
README_FN
{
...
...
@@ -506,7 +505,7 @@ func TestNoCluster(t *testing.T) {
}
func
BenchmarkConsecutivePut
(
b
*
testing
.
B
)
{
r
:=
rand
bo
.
N
e
w
()
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
N
o
w
()
.
UnixNano
()))
var
blocks
[][]
byte
var
keys
[]
datastore
.
Key
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
...
...
@@ -536,7 +535,7 @@ func BenchmarkConsecutivePut(b *testing.B) {
}
func
BenchmarkBatchedPut
(
b
*
testing
.
B
)
{
r
:=
rand
bo
.
N
e
w
()
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
N
o
w
()
.
UnixNano
()))
var
blocks
[][]
byte
var
keys
[]
datastore
.
Key
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment