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-unixfs
Commits
00efa963
Commit
00efa963
authored
Mar 09, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add benchmark
parent
d7f1750f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
2 deletions
+31
-2
mod/dagmodifier_test.go
mod/dagmodifier_test.go
+31
-2
No files found.
mod/dagmodifier_test.go
View file @
00efa963
...
@@ -23,7 +23,7 @@ import (
...
@@ -23,7 +23,7 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
)
)
func
getMockDagServ
(
t
*
testing
.
T
)
mdag
.
DAGService
{
func
getMockDagServ
(
t
testing
.
T
B
)
mdag
.
DAGService
{
dstore
:=
ds
.
NewMapDatastore
()
dstore
:=
ds
.
NewMapDatastore
()
tsds
:=
sync
.
MutexWrap
(
dstore
)
tsds
:=
sync
.
MutexWrap
(
dstore
)
bstore
:=
blockstore
.
NewBlockstore
(
tsds
)
bstore
:=
blockstore
.
NewBlockstore
(
tsds
)
...
@@ -34,7 +34,7 @@ func getMockDagServ(t *testing.T) mdag.DAGService {
...
@@ -34,7 +34,7 @@ func getMockDagServ(t *testing.T) mdag.DAGService {
return
mdag
.
NewDAGService
(
bserv
)
return
mdag
.
NewDAGService
(
bserv
)
}
}
func
getNode
(
t
*
testing
.
T
,
dserv
mdag
.
DAGService
,
size
int64
)
([]
byte
,
*
mdag
.
Node
)
{
func
getNode
(
t
testing
.
T
B
,
dserv
mdag
.
DAGService
,
size
int64
)
([]
byte
,
*
mdag
.
Node
)
{
in
:=
io
.
LimitReader
(
u
.
NewTimeSeededRand
(),
size
)
in
:=
io
.
LimitReader
(
u
.
NewTimeSeededRand
(),
size
)
node
,
err
:=
imp
.
BuildTrickleDagFromReader
(
in
,
dserv
,
nil
,
&
chunk
.
SizeSplitter
{
500
})
node
,
err
:=
imp
.
BuildTrickleDagFromReader
(
in
,
dserv
,
nil
,
&
chunk
.
SizeSplitter
{
500
})
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -423,6 +423,35 @@ func TestDagTruncate(t *testing.T) {
...
@@ -423,6 +423,35 @@ func TestDagTruncate(t *testing.T) {
}
}
}
}
func
BenchmarkDagmodWrite
(
b
*
testing
.
B
)
{
b
.
StopTimer
()
dserv
:=
getMockDagServ
(
b
)
_
,
n
:=
getNode
(
b
,
dserv
,
0
)
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
wrsize
:=
4096
dagmod
,
err
:=
NewDagModifier
(
ctx
,
n
,
dserv
,
nil
,
&
chunk
.
SizeSplitter
{
Size
:
512
})
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
buf
:=
make
([]
byte
,
b
.
N
*
wrsize
)
u
.
NewTimeSeededRand
()
.
Read
(
buf
)
b
.
StartTimer
()
b
.
SetBytes
(
int64
(
wrsize
))
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
n
,
err
:=
dagmod
.
Write
(
buf
[
i
*
wrsize
:
(
i
+
1
)
*
wrsize
])
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
if
n
!=
wrsize
{
b
.
Fatal
(
"Wrote bad size"
)
}
}
}
func
arrComp
(
a
,
b
[]
byte
)
error
{
func
arrComp
(
a
,
b
[]
byte
)
error
{
if
len
(
a
)
!=
len
(
b
)
{
if
len
(
a
)
!=
len
(
b
)
{
return
fmt
.
Errorf
(
"Arrays differ in length. %d != %d"
,
len
(
a
),
len
(
b
))
return
fmt
.
Errorf
(
"Arrays differ in length. %d != %d"
,
len
(
a
),
len
(
b
))
...
...
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