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
6b8d3e3c
Commit
6b8d3e3c
authored
Jan 20, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use extracted unit package
parent
de2cb5d8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
83 deletions
+52
-83
test/epictest/addcat_test.go
test/epictest/addcat_test.go
+2
-1
test/epictest/bench_test.go
test/epictest/bench_test.go
+48
-47
test/epictest/three_legged_cat_test.go
test/epictest/three_legged_cat_test.go
+2
-1
test/epictest/unit.go
test/epictest/unit.go
+0
-10
test/epictest/unit_test.go
test/epictest/unit_test.go
+0
-24
No files found.
test/epictest/addcat_test.go
View file @
6b8d3e3c
...
...
@@ -15,6 +15,7 @@ import (
coreunix
"github.com/jbenet/go-ipfs/core/coreunix"
mocknet
"github.com/jbenet/go-ipfs/p2p/net/mock"
"github.com/jbenet/go-ipfs/p2p/peer"
"github.com/jbenet/go-ipfs/thirdparty/unit"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
...
...
@@ -28,7 +29,7 @@ func Test1KBInstantaneous(t *testing.T) {
BlockstoreLatency
:
0
,
}
if
err
:=
DirectAddCat
(
RandomBytes
(
1
*
KB
),
conf
);
err
!=
nil
{
if
err
:=
DirectAddCat
(
RandomBytes
(
1
*
unit
.
KB
),
conf
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
...
...
test/epictest/bench_test.go
View file @
6b8d3e3c
...
...
@@ -3,6 +3,7 @@ package epictest
import
(
"testing"
"github.com/jbenet/go-ipfs/thirdparty/unit"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
...
...
@@ -22,62 +23,62 @@ func benchmarkAddCat(numBytes int64, conf testutil.LatencyConfig, b *testing.B)
var
instant
=
testutil
.
LatencyConfig
{}
.
All_Instantaneous
()
func
BenchmarkInstantaneousAddCat1KB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
KB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat4MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat8MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat16MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat32MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat64MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat1KB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
unit
.
KB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
unit
.
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
unit
.
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat4MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
unit
.
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat8MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
unit
.
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat16MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
unit
.
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat32MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
unit
.
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat64MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
unit
.
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
unit
.
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
unit
.
MB
,
instant
,
b
)
}
var
routing
=
testutil
.
LatencyConfig
{}
.
Routing_Slow
()
func
BenchmarkRoutingSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat4MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat8MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat16MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat32MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat64MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat512MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
512
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
unit
.
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
unit
.
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat4MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
unit
.
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat8MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
unit
.
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat16MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
unit
.
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat32MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
unit
.
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat64MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
unit
.
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
unit
.
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
unit
.
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat512MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
512
*
unit
.
MB
,
routing
,
b
)
}
var
network
=
testutil
.
LatencyConfig
{}
.
Network_NYtoSF
()
func
BenchmarkNetworkSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat4MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat8MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat16MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat32MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat64MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
unit
.
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
unit
.
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat4MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
unit
.
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat8MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
unit
.
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat16MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
unit
.
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat32MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
unit
.
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat64MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
unit
.
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
unit
.
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
unit
.
MB
,
network
,
b
)
}
var
hdd
=
testutil
.
LatencyConfig
{}
.
Blockstore_7200RPM
()
func
BenchmarkBlockstoreSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat4MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat8MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat16MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat32MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat64MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
unit
.
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
unit
.
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat4MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
unit
.
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat8MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
unit
.
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat16MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
unit
.
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat32MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
unit
.
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat64MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
unit
.
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
unit
.
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
unit
.
MB
,
hdd
,
b
)
}
var
mixed
=
testutil
.
LatencyConfig
{}
.
Network_NYtoSF
()
.
Blockstore_SlowSSD2014
()
.
Routing_Slow
()
func
BenchmarkMixedAddCat1MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat2MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat4MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat8MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat16MBX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat32MBX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat64MBX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat1MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
unit
.
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat2MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
unit
.
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat4MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
4
*
unit
.
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat8MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
8
*
unit
.
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat16MBX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
16
*
unit
.
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat32MBX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
32
*
unit
.
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat64MBX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
64
*
unit
.
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
unit
.
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
unit
.
MB
,
mixed
,
b
)
}
test/epictest/three_legged_cat_test.go
View file @
6b8d3e3c
...
...
@@ -11,6 +11,7 @@ import (
coreunix
"github.com/jbenet/go-ipfs/core/coreunix"
mocknet
"github.com/jbenet/go-ipfs/p2p/net/mock"
"github.com/jbenet/go-ipfs/p2p/peer"
"github.com/jbenet/go-ipfs/thirdparty/unit"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
...
...
@@ -21,7 +22,7 @@ func TestThreeLeggedCat(t *testing.T) {
RoutingLatency
:
0
,
BlockstoreLatency
:
0
,
}
if
err
:=
RunThreeLeggedCat
(
RandomBytes
(
1
*
KB
),
conf
);
err
!=
nil
{
if
err
:=
RunThreeLeggedCat
(
RandomBytes
(
1
*
unit
.
KB
),
conf
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
...
...
test/epictest/unit.go
View file @
6b8d3e3c
package
epictest
const
(
_
=
iota
// ignore first value by assigning to blank identifier
KB
=
1
<<
(
10
*
iota
)
MB
GB
TB
PB
EB
)
test/epictest/unit_test.go
View file @
6b8d3e3c
package
epictest
import
"testing"
// and the award for most meta goes to...
func
TestByteSizeUnit
(
t
*
testing
.
T
)
{
if
1
*
KB
!=
1
*
1024
{
t
.
Fatal
(
1
*
KB
)
}
if
1
*
MB
!=
1
*
1024
*
1024
{
t
.
Fail
()
}
if
1
*
GB
!=
1
*
1024
*
1024
*
1024
{
t
.
Fail
()
}
if
1
*
TB
!=
1
*
1024
*
1024
*
1024
*
1024
{
t
.
Fail
()
}
if
1
*
PB
!=
1
*
1024
*
1024
*
1024
*
1024
*
1024
{
t
.
Fail
()
}
if
1
*
EB
!=
1
*
1024
*
1024
*
1024
*
1024
*
1024
*
1024
{
t
.
Fail
()
}
}
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