Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
f9443fd2
提交
f9443fd2
authored
10月 31, 2018
作者:
hannahhoward
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WIP 2 Go Benchmark -- with duplicate blocks even w/ new BS PR
License: MIT Signed-off-by:
hannahhoward
<
hannah@hannahhoward.net
>
上级
f796b249
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
30 行增加
和
12 行删除
+30
-12
bitswap_session_test.go
test/integration/bitswap_session_test.go
+30
-12
没有找到文件。
test/integration/bitswap_session_test.go
浏览文件 @
f9443fd2
...
...
@@ -3,22 +3,26 @@ package integrationtest
import
(
"bytes"
"context"
"github.com/ipfs/go-ipfs/core/coreapi"
"github.com/ipfs/go-ipfs/core/coreapi/interface"
"github.com/ipfs/go-ipfs/core/coreunix"
"github.com/ipfs/go-ipfs/thirdparty/unit"
"fmt"
"gx/ipfs/QmNkxFCmPtr2RQxjZNRCNryLud4L9wMEiBJsLgF14MqTHj/go-bitswap"
"io"
"math"
"math/rand"
"testing"
"time"
"github.com/ipfs/go-ipfs/core/coreapi"
"github.com/ipfs/go-ipfs/core/coreapi/interface"
"github.com/ipfs/go-ipfs/core/coreunix"
"github.com/ipfs/go-ipfs/thirdparty/unit"
"gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/net/mock"
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/core/mock"
"gx/ipfs/QmUDTcnDp2WssbmiDLC6aYurUeyt7QeRakHUQMxA2mZ5iB/go-libp2p/p2p/net/mock"
)
func
TestBitswapSessions
(
b
*
testing
.
T
)
{
func
BenchmarkBitswapSessions
(
b
*
testing
.
B
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
const
numPeers
=
6
...
...
@@ -55,6 +59,16 @@ func TestBitswapSessions(b *testing.T) {
continue
}
pID1
:=
n1
.
PeerHost
.
ID
()
pID2
:=
n2
.
PeerHost
.
ID
()
links
:=
mn
.
LinksBetweenPeers
(
pID1
,
pID2
)
for
_
,
link
:=
range
links
{
link
.
SetOptions
(
mocknet
.
LinkOptions
{
Latency
:
(
time
.
Duration
(
10
+
rand
.
Intn
(
200
))
*
time
.
Millisecond
),
// TODO add to conf. This is tricky because we want 0 values to be functional.
Bandwidth
:
300000
,
})
}
p2
:=
n2
.
PeerHost
.
Peerstore
()
.
PeerInfo
(
n2
.
PeerHost
.
ID
())
if
err
:=
n1
.
PeerHost
.
Connect
(
ctx
,
p2
);
err
!=
nil
{
b
.
Fatal
(
err
)
...
...
@@ -62,7 +76,7 @@ func TestBitswapSessions(b *testing.T) {
}
}
randomBytes
:=
RandomBytes
(
10
0
*
unit
.
MB
)
randomBytes
:=
RandomBytes
(
10
*
unit
.
MB
)
added
,
err
:=
coreunix
.
Add
(
nodes
[
0
],
bytes
.
NewReader
(
randomBytes
))
if
err
!=
nil
{
b
.
Fatal
(
err
)
...
...
@@ -73,6 +87,8 @@ func TestBitswapSessions(b *testing.T) {
b
.
Fatal
(
err
)
}
blocks
:=
make
([]
uint64
,
len
(
nodes
))
// get it out.
for
i
,
n
:=
range
nodes
{
// skip first because block not in its exchange. will hang.
...
...
@@ -80,8 +96,9 @@ func TestBitswapSessions(b *testing.T) {
continue
}
//testName := fmt.Sprintf("Node %d", i)
//b.Run(testName, func(b *testing.B) {
nApi
:=
coreapi
.
NewCoreAPI
(
n
)
got
,
err
:=
nApi
.
Unixfs
()
.
Get
(
ctx
,
ap
)
if
err
!=
nil
{
b
.
Error
(
err
)
...
...
@@ -93,12 +110,13 @@ func TestBitswapSessions(b *testing.T) {
b
.
Fatal
(
"catted data does not match added data"
)
}
for
_
,
bPeer
:=
range
nodes
{
for
j
,
bPeer
:=
range
nodes
{
bstat
,
err
:=
bPeer
.
Exchange
.
(
*
bitswap
.
Bitswap
)
.
Stat
()
if
err
!=
nil
{
b
.
Fatal
(
err
)
}
b
.
Logf
(
"%s blocks sent: %d"
,
bPeer
.
Identity
,
bstat
.
BlocksSent
)
fmt
.
Printf
(
"%d: <-%d blocks sent: %d
\n
"
,
i
,
j
,
bstat
.
BlocksSent
-
blocks
[
j
])
blocks
[
j
]
=
bstat
.
BlocksSent
}
bstat
,
err
:=
n
.
Exchange
.
(
*
bitswap
.
Bitswap
)
.
Stat
()
...
...
@@ -106,8 +124,8 @@ func TestBitswapSessions(b *testing.T) {
b
.
Fatal
(
err
)
}
b
.
Logf
(
"%d %s got data."
,
i
,
n
.
Identity
)
b
.
Logf
(
"%s duplicate blocks received: %d"
,
n
.
Identity
,
bstat
.
DupBlksReceived
)
fmt
.
Printf
(
"%d: duplicate blocks received: %d
\n
"
,
i
,
bstat
.
DupBlksReceived
)
// }
)
}
cancel
()
return
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论