basic timers and counters
This commit is contained in:
parent
2256a7237c
commit
d7631fb997
@ -98,6 +98,7 @@ func runBaselineClient(t *TestEnvironment) error {
|
|||||||
t.RecordMessage("file cid: %s", fcid)
|
t.RecordMessage("file cid: %s", fcid)
|
||||||
|
|
||||||
// start deal
|
// start deal
|
||||||
|
t1 := time.Now()
|
||||||
deal := startDeal(ctx, minerAddr.ActorAddr, client, fcid)
|
deal := startDeal(ctx, minerAddr.ActorAddr, client, fcid)
|
||||||
t.RecordMessage("started deal: %s", deal)
|
t.RecordMessage("started deal: %s", deal)
|
||||||
|
|
||||||
@ -106,11 +107,13 @@ func runBaselineClient(t *TestEnvironment) error {
|
|||||||
|
|
||||||
t.RecordMessage("waiting for deal to be sealed")
|
t.RecordMessage("waiting for deal to be sealed")
|
||||||
waitDealSealed(t, ctx, client, deal)
|
waitDealSealed(t, ctx, client, deal)
|
||||||
|
t.D().ResettingHistogram("deal.sealed").Update(int64(time.Since(t1)))
|
||||||
|
|
||||||
carExport := true
|
carExport := true
|
||||||
|
|
||||||
t.RecordMessage("trying to retrieve %s", fcid)
|
t.RecordMessage("trying to retrieve %s", fcid)
|
||||||
retrieveData(t, ctx, err, client, fcid, carExport, data)
|
retrieveData(t, ctx, err, client, fcid, carExport, data)
|
||||||
|
t.D().ResettingHistogram("deal.retrieved").Update(int64(time.Since(t1)))
|
||||||
|
|
||||||
t.SyncClient.MustSignalEntry(ctx, stateStopMining)
|
t.SyncClient.MustSignalEntry(ctx, stateStopMining)
|
||||||
|
|
||||||
@ -164,10 +167,15 @@ loop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func retrieveData(t *TestEnvironment, ctx context.Context, err error, client api.FullNode, fcid cid.Cid, carExport bool, data []byte) {
|
func retrieveData(t *TestEnvironment, ctx context.Context, err error, client api.FullNode, fcid cid.Cid, carExport bool, data []byte) {
|
||||||
|
t1 := time.Now()
|
||||||
offers, err := client.ClientFindData(ctx, fcid)
|
offers, err := client.ClientFindData(ctx, fcid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
for _, o := range offers {
|
||||||
|
t.D().Counter(fmt.Sprintf("find-data.offer.%s", o.Miner)).Inc(1)
|
||||||
|
}
|
||||||
|
t.D().ResettingHistogram("find-data").Update(int64(time.Since(t1)))
|
||||||
|
|
||||||
if len(offers) < 1 {
|
if len(offers) < 1 {
|
||||||
panic("no offers")
|
panic("no offers")
|
||||||
@ -188,10 +196,12 @@ func retrieveData(t *TestEnvironment, ctx context.Context, err error, client api
|
|||||||
Path: filepath.Join(rpath, "ret"),
|
Path: filepath.Join(rpath, "ret"),
|
||||||
IsCAR: carExport,
|
IsCAR: carExport,
|
||||||
}
|
}
|
||||||
|
t1 = time.Now()
|
||||||
err = client.ClientRetrieve(ctx, offers[0].Order(caddr), ref)
|
err = client.ClientRetrieve(ctx, offers[0].Order(caddr), ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
t.D().ResettingHistogram("retrieve-data").Update(int64(time.Since(t1)))
|
||||||
|
|
||||||
rdata, err := ioutil.ReadFile(filepath.Join(rpath, "ret"))
|
rdata, err := ioutil.ReadFile(filepath.Join(rpath, "ret"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/testground/sdk-go/sync"
|
"github.com/testground/sdk-go/sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -28,6 +29,9 @@ func runMiner(t *TestEnvironment) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.RecordMessage("block delay: %v", build.BlockDelay)
|
||||||
|
t.D().Gauge("miner.block-delay").Update(build.BlockDelay)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
clients := t.IntParam("clients")
|
clients := t.IntParam("clients")
|
||||||
@ -50,6 +54,8 @@ func runMiner(t *TestEnvironment) error {
|
|||||||
time.Sleep(time.Duration(100 + rand.Intn(int(100*time.Millisecond))))
|
time.Sleep(time.Duration(100 + rand.Intn(int(100*time.Millisecond))))
|
||||||
|
|
||||||
err := miner.MineOne(ctx, func(bool) {
|
err := miner.MineOne(ctx, func(bool) {
|
||||||
|
|
||||||
|
t.D().Counter("miner.mine").Inc(1)
|
||||||
// after a block is mined
|
// after a block is mined
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user