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-dms3
Commits
1907e66e
Commit
1907e66e
authored
Mar 28, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add benchmark for hamt walking
License: MIT Signed-off-by:
Steven Allen
<
steven@stebalien.com
>
parent
f1ae13d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
unixfs/hamt/hamt_test.go
unixfs/hamt/hamt_test.go
+43
-0
No files found.
unixfs/hamt/hamt_test.go
View file @
1907e66e
...
...
@@ -523,6 +523,49 @@ func printDiff(ds ipld.DAGService, a, b *dag.ProtoNode) {
}
}
func
BenchmarkHAMTWalk
(
b
*
testing
.
B
)
{
ctx
:=
context
.
Background
()
ds
:=
mdtest
.
Mock
()
sh
,
_
:=
NewShard
(
ds
,
256
)
nd
,
err
:=
sh
.
Node
()
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
err
=
ds
.
Add
(
ctx
,
nd
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
ds
.
Add
(
ctx
,
ft
.
EmptyDirNode
())
s
,
err
:=
NewHamtFromDag
(
ds
,
nd
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
for
j
:=
0
;
j
<
1000
;
j
++
{
err
=
s
.
Set
(
ctx
,
fmt
.
Sprintf
(
"%d"
,
j
),
ft
.
EmptyDirNode
())
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
}
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
cnt
:=
0
err
=
s
.
ForEachLink
(
ctx
,
func
(
l
*
ipld
.
Link
)
error
{
cnt
++
return
nil
})
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
if
cnt
<
1000
{
b
.
Fatal
(
"expected 100 children"
)
}
}
}
func
BenchmarkHAMTSet
(
b
*
testing
.
B
)
{
ctx
:=
context
.
Background
()
...
...
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