Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
61c70837
Unverified
Commit
61c70837
authored
Oct 14, 2020
by
acud
Committed by
GitHub
Oct 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add basic pipeline benchmarks (#836)
* add basic pipeline/splitter benchmarks
parent
f8843d15
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
126 additions
and
0 deletions
+126
-0
builder_test.go
pkg/file/pipeline/builder/builder_test.go
+64
-0
splitter_test.go
pkg/file/splitter/splitter_test.go
+62
-0
No files found.
pkg/file/pipeline/builder/builder_test.go
View file @
61c70837
...
...
@@ -7,8 +7,10 @@ package builder_test
import
(
"bytes"
"context"
"crypto/rand"
"encoding/hex"
"fmt"
"strconv"
"testing"
"github.com/ethersphere/bee/pkg/file/pipeline/builder"
...
...
@@ -76,3 +78,65 @@ func TestAllVectors(t *testing.T) {
})
}
}
/*
go test -v -bench=. -run Bench -benchmem
goos: linux
goarch: amd64
pkg: github.com/ethersphere/bee/pkg/file/pipeline/builder
BenchmarkPipeline
BenchmarkPipeline/1000-bytes
BenchmarkPipeline/1000-bytes-4 14475 75170 ns/op 63611 B/op 333 allocs/op
BenchmarkPipeline/10000-bytes
BenchmarkPipeline/10000-bytes-4 2775 459275 ns/op 321825 B/op 1826 allocs/op
BenchmarkPipeline/100000-bytes
BenchmarkPipeline/100000-bytes-4 334 3523558 ns/op 1891672 B/op 11994 allocs/op
BenchmarkPipeline/1000000-bytes
BenchmarkPipeline/1000000-bytes-4 36 33140883 ns/op 17745116 B/op 114170 allocs/op
BenchmarkPipeline/10000000-bytes
BenchmarkPipeline/10000000-bytes-4 4 304759595 ns/op 175378648 B/op 1135082 allocs/op
BenchmarkPipeline/100000000-bytes
BenchmarkPipeline/100000000-bytes-4 1 3064439098 ns/op 1751509528 B/op 11342736 allocs/op
PASS
ok github.com/ethersphere/bee/pkg/file/pipeline/builder 17.599s
*/
func
BenchmarkPipeline
(
b
*
testing
.
B
)
{
for
_
,
count
:=
range
[]
int
{
1000
,
// 1k
10000
,
// 10 k
100000
,
// 100 k
1000000
,
// 1 mb
10000000
,
// 10 mb
100000000
,
// 100 mb
}
{
b
.
Run
(
strconv
.
Itoa
(
count
)
+
"-bytes"
,
func
(
b
*
testing
.
B
)
{
for
n
:=
0
;
n
<
b
.
N
;
n
++
{
benchmarkPipeline
(
b
,
count
)
}
})
}
}
func
benchmarkPipeline
(
b
*
testing
.
B
,
count
int
)
{
b
.
StopTimer
()
m
:=
mock
.
NewStorer
()
p
:=
builder
.
NewPipelineBuilder
(
context
.
Background
(),
m
,
storage
.
ModePutUpload
,
false
)
data
:=
make
([]
byte
,
count
)
_
,
err
:=
rand
.
Read
(
data
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
b
.
StartTimer
()
_
,
err
=
p
.
Write
(
data
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
_
,
err
=
p
.
Sum
()
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
}
pkg/file/splitter/splitter_test.go
View file @
61c70837
...
...
@@ -7,6 +7,8 @@ package splitter_test
import
(
"bytes"
"context"
"crypto/rand"
"strconv"
"testing"
"time"
...
...
@@ -181,3 +183,63 @@ func TestUnalignedSplit(t *testing.T) {
t
.
Fatal
(
"timeout"
)
}
}
/*
go test -v -bench=. -run Bench -benchmem
goos: linux
goarch: amd64
pkg: github.com/ethersphere/bee/pkg/file/splitter
BenchmarkSplitter
BenchmarkSplitter/1000-bytes
BenchmarkSplitter/1000-bytes-4 12667 95965 ns/op 154870 B/op 367 allocs/op
BenchmarkSplitter/10000-bytes
BenchmarkSplitter/10000-bytes-4 2808 418753 ns/op 369764 B/op 1624 allocs/op
BenchmarkSplitter/100000-bytes
BenchmarkSplitter/100000-bytes-4 349 3342003 ns/op 2042891 B/op 11810 allocs/op
BenchmarkSplitter/1000000-bytes
BenchmarkSplitter/1000000-bytes-4 33 30905753 ns/op 18825910 B/op 113721 allocs/op
BenchmarkSplitter/10000000-bytes
BenchmarkSplitter/10000000-bytes-4 4 295615658 ns/op 186417904 B/op 1132527 allocs/op
BenchmarkSplitter/100000000-bytes
BenchmarkSplitter/100000000-bytes-4 1 2972826021 ns/op 1861374352 B/op 11321235 allocs/op
PASS
ok github.com/ethersphere/bee/pkg/file/splitter 22.476s
*/
func
BenchmarkSplitter
(
b
*
testing
.
B
)
{
for
_
,
count
:=
range
[]
int
{
1000
,
// 1k
10000
,
// 10 k
100000
,
// 100 k
1000000
,
// 1 mb
10000000
,
// 10 mb
100000000
,
// 100 mb
}
{
b
.
Run
(
strconv
.
Itoa
(
count
)
+
"-bytes"
,
func
(
b
*
testing
.
B
)
{
for
n
:=
0
;
n
<
b
.
N
;
n
++
{
benchmarkSplitter
(
b
,
count
)
}
})
}
}
func
benchmarkSplitter
(
b
*
testing
.
B
,
count
int
)
{
b
.
StopTimer
()
m
:=
mock
.
NewStorer
()
s
:=
splitter
.
NewSimpleSplitter
(
m
,
storage
.
ModePutUpload
)
data
:=
make
([]
byte
,
count
)
_
,
err
:=
rand
.
Read
(
data
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
testDataReader
:=
file
.
NewSimpleReadCloser
(
data
)
b
.
StartTimer
()
_
,
err
=
s
.
Split
(
context
.
Background
(),
testDataReader
,
int64
(
len
(
data
)),
false
)
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
}
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