Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
007ffd40
提交
007ffd40
authored
1月 10, 2015
作者:
Brian Tiger Chow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: move LatencyConfig
上级
836e5cab
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
72 行增加
和
64 行删除
+72
-64
addcat_test.go
test/epictest/addcat_test.go
+8
-7
bench_test.go
test/epictest/bench_test.go
+11
-7
core.go
test/epictest/core.go
+2
-1
test_config.go
test/epictest/test_config.go
+0
-47
three_legged_cat_test.go
test/epictest/three_legged_cat_test.go
+3
-2
latency_config.go
util/testutil/latency_config.go
+48
-0
没有找到文件。
test/epictest/addcat_test.go
浏览文件 @
007ffd40
...
...
@@ -13,12 +13,13 @@ import (
random
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random"
mocknet
"github.com/jbenet/go-ipfs/p2p/net/mock"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
const
kSeed
=
1
func
Test1KBInstantaneous
(
t
*
testing
.
T
)
{
conf
:=
Config
{
conf
:=
testutil
.
Latency
Config
{
NetworkLatency
:
0
,
RoutingLatency
:
0
,
BlockstoreLatency
:
0
,
...
...
@@ -31,7 +32,7 @@ func Test1KBInstantaneous(t *testing.T) {
func
TestDegenerateSlowBlockstore
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
Config
{
BlockstoreLatency
:
50
*
time
.
Millisecond
}
conf
:=
testutil
.
Latency
Config
{
BlockstoreLatency
:
50
*
time
.
Millisecond
}
if
err
:=
AddCatPowers
(
conf
,
128
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -39,7 +40,7 @@ func TestDegenerateSlowBlockstore(t *testing.T) {
func
TestDegenerateSlowNetwork
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
Config
{
NetworkLatency
:
400
*
time
.
Millisecond
}
conf
:=
testutil
.
Latency
Config
{
NetworkLatency
:
400
*
time
.
Millisecond
}
if
err
:=
AddCatPowers
(
conf
,
128
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -47,7 +48,7 @@ func TestDegenerateSlowNetwork(t *testing.T) {
func
TestDegenerateSlowRouting
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
Config
{
RoutingLatency
:
400
*
time
.
Millisecond
}
conf
:=
testutil
.
Latency
Config
{
RoutingLatency
:
400
*
time
.
Millisecond
}
if
err
:=
AddCatPowers
(
conf
,
128
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -55,13 +56,13 @@ func TestDegenerateSlowRouting(t *testing.T) {
func
Test100MBMacbookCoastToCoast
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
Config
{}
.
Network_NYtoSF
()
.
Blockstore_SlowSSD2014
()
.
Routing_Slow
()
conf
:=
testutil
.
Latency
Config
{}
.
Network_NYtoSF
()
.
Blockstore_SlowSSD2014
()
.
Routing_Slow
()
if
err
:=
DirectAddCat
(
RandomBytes
(
100
*
1024
*
1024
),
conf
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
AddCatPowers
(
conf
Config
,
megabytesMax
int64
)
error
{
func
AddCatPowers
(
conf
testutil
.
Latency
Config
,
megabytesMax
int64
)
error
{
var
i
int64
for
i
=
1
;
i
<
megabytesMax
;
i
=
i
*
2
{
fmt
.
Printf
(
"%d MB
\n
"
,
i
)
...
...
@@ -78,7 +79,7 @@ func RandomBytes(n int64) []byte {
return
data
.
Bytes
()
}
func
DirectAddCat
(
data
[]
byte
,
conf
Config
)
error
{
func
DirectAddCat
(
data
[]
byte
,
conf
testutil
.
Latency
Config
)
error
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
const
numPeers
=
2
...
...
test/epictest/bench_test.go
浏览文件 @
007ffd40
package
epictest
import
"testing"
import
(
"testing"
func
benchmarkAddCat
(
numBytes
int64
,
conf
Config
,
b
*
testing
.
B
)
{
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
func
benchmarkAddCat
(
numBytes
int64
,
conf
testutil
.
LatencyConfig
,
b
*
testing
.
B
)
{
b
.
StopTimer
()
b
.
SetBytes
(
numBytes
)
...
...
@@ -16,7 +20,7 @@ func benchmarkAddCat(numBytes int64, conf Config, b *testing.B) {
}
}
var
instant
=
Config
{}
.
All_Instantaneous
()
var
instant
=
testutil
.
Latency
Config
{}
.
All_Instantaneous
()
func
BenchmarkInstantaneousAddCat1KB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
KB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
instant
,
b
)
}
...
...
@@ -29,7 +33,7 @@ func BenchmarkInstantaneousAddCat64MB(b *testing.B) { benchmarkAddCat(64*MB, in
func
BenchmarkInstantaneousAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
instant
,
b
)
}
var
routing
=
Config
{}
.
Routing_Slow
()
var
routing
=
testutil
.
Latency
Config
{}
.
Routing_Slow
()
func
BenchmarkRoutingSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
routing
,
b
)
}
...
...
@@ -42,7 +46,7 @@ func BenchmarkRoutingSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*MB, rou
func
BenchmarkRoutingSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat512MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
512
*
MB
,
routing
,
b
)
}
var
network
=
Config
{}
.
Network_NYtoSF
()
var
network
=
testutil
.
Latency
Config
{}
.
Network_NYtoSF
()
func
BenchmarkNetworkSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
network
,
b
)
}
...
...
@@ -54,7 +58,7 @@ func BenchmarkNetworkSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*MB, netw
func
BenchmarkNetworkSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
network
,
b
)
}
var
hdd
=
Config
{}
.
Blockstore_7200RPM
()
var
hdd
=
testutil
.
Latency
Config
{}
.
Blockstore_7200RPM
()
func
BenchmarkBlockstoreSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
hdd
,
b
)
}
...
...
@@ -66,7 +70,7 @@ func BenchmarkBlockstoreSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*MB, h
func
BenchmarkBlockstoreSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
hdd
,
b
)
}
var
mixed
=
Config
{}
.
Network_NYtoSF
()
.
Blockstore_SlowSSD2014
()
.
Routing_Slow
()
var
mixed
=
testutil
.
Latency
Config
{}
.
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
)
}
...
...
test/epictest/core.go
浏览文件 @
007ffd40
...
...
@@ -9,6 +9,7 @@ import (
blockstore
"github.com/jbenet/go-ipfs/blocks/blockstore"
blockservice
"github.com/jbenet/go-ipfs/blockservice"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
exchange
"github.com/jbenet/go-ipfs/exchange"
bitswap
"github.com/jbenet/go-ipfs/exchange/bitswap"
bsnet
"github.com/jbenet/go-ipfs/exchange/bitswap/network"
...
...
@@ -130,7 +131,7 @@ func (r *repo) Exchange() exchange.Interface {
return
r
.
exchange
}
func
MocknetTestRepo
(
p
peer
.
ID
,
h
host
.
Host
,
conf
Config
)
RepoFactory
{
func
MocknetTestRepo
(
p
peer
.
ID
,
h
host
.
Host
,
conf
testutil
.
Latency
Config
)
RepoFactory
{
return
func
(
ctx
context
.
Context
)
(
Repo
,
error
)
{
const
kWriteCacheElems
=
100
const
alwaysSendToPeer
=
true
...
...
test/epictest/test_config.go
浏览文件 @
007ffd40
package
epictest
import
"time"
type
Config
struct
{
BlockstoreLatency
time
.
Duration
NetworkLatency
time
.
Duration
RoutingLatency
time
.
Duration
}
func
(
c
Config
)
All_Instantaneous
()
Config
{
// Could use a zero value but whatever. Consistency of interface
c
.
NetworkLatency
=
0
c
.
RoutingLatency
=
0
c
.
BlockstoreLatency
=
0
return
c
}
func
(
c
Config
)
Network_NYtoSF
()
Config
{
c
.
NetworkLatency
=
20
*
time
.
Millisecond
return
c
}
func
(
c
Config
)
Network_IntraDatacenter2014
()
Config
{
c
.
NetworkLatency
=
250
*
time
.
Microsecond
return
c
}
func
(
c
Config
)
Blockstore_FastSSD2014
()
Config
{
const
iops
=
100000
c
.
BlockstoreLatency
=
(
1
/
iops
)
*
time
.
Second
return
c
}
func
(
c
Config
)
Blockstore_SlowSSD2014
()
Config
{
c
.
BlockstoreLatency
=
150
*
time
.
Microsecond
return
c
}
func
(
c
Config
)
Blockstore_7200RPM
()
Config
{
c
.
BlockstoreLatency
=
8
*
time
.
Millisecond
return
c
}
func
(
c
Config
)
Routing_Slow
()
Config
{
c
.
RoutingLatency
=
200
*
time
.
Millisecond
return
c
}
test/epictest/three_legged_cat_test.go
浏览文件 @
007ffd40
...
...
@@ -9,10 +9,11 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
mocknet
"github.com/jbenet/go-ipfs/p2p/net/mock"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
func
TestThreeLeggedCat
(
t
*
testing
.
T
)
{
conf
:=
Config
{
conf
:=
testutil
.
Latency
Config
{
NetworkLatency
:
0
,
RoutingLatency
:
0
,
BlockstoreLatency
:
0
,
...
...
@@ -22,7 +23,7 @@ func TestThreeLeggedCat(t *testing.T) {
}
}
func
RunThreeLeggedCat
(
data
[]
byte
,
conf
Config
)
error
{
func
RunThreeLeggedCat
(
data
[]
byte
,
conf
testutil
.
Latency
Config
)
error
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
const
numPeers
=
3
...
...
util/testutil/latency_config.go
0 → 100644
浏览文件 @
007ffd40
package
testutil
import
"time"
type
LatencyConfig
struct
{
BlockstoreLatency
time
.
Duration
NetworkLatency
time
.
Duration
RoutingLatency
time
.
Duration
}
func
(
c
LatencyConfig
)
All_Instantaneous
()
LatencyConfig
{
// Could use a zero value but whatever. Consistency of interface
c
.
NetworkLatency
=
0
c
.
RoutingLatency
=
0
c
.
BlockstoreLatency
=
0
return
c
}
func
(
c
LatencyConfig
)
Network_NYtoSF
()
LatencyConfig
{
c
.
NetworkLatency
=
20
*
time
.
Millisecond
return
c
}
func
(
c
LatencyConfig
)
Network_IntraDatacenter2014
()
LatencyConfig
{
c
.
NetworkLatency
=
250
*
time
.
Microsecond
return
c
}
func
(
c
LatencyConfig
)
Blockstore_FastSSD2014
()
LatencyConfig
{
const
iops
=
100000
c
.
BlockstoreLatency
=
(
1
/
iops
)
*
time
.
Second
return
c
}
func
(
c
LatencyConfig
)
Blockstore_SlowSSD2014
()
LatencyConfig
{
c
.
BlockstoreLatency
=
150
*
time
.
Microsecond
return
c
}
func
(
c
LatencyConfig
)
Blockstore_7200RPM
()
LatencyConfig
{
c
.
BlockstoreLatency
=
8
*
time
.
Millisecond
return
c
}
func
(
c
LatencyConfig
)
Routing_Slow
()
LatencyConfig
{
c
.
RoutingLatency
=
200
*
time
.
Millisecond
return
c
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论