basic timers and counters

This commit is contained in:
Anton Evangelatov 2020-06-26 14:09:58 +02:00
parent 2256a7237c
commit d7631fb997
2 changed files with 16 additions and 0 deletions

View File

@ -98,6 +98,7 @@ func runBaselineClient(t *TestEnvironment) error {
t.RecordMessage("file cid: %s", fcid)
// start deal
t1 := time.Now()
deal := startDeal(ctx, minerAddr.ActorAddr, client, fcid)
t.RecordMessage("started deal: %s", deal)
@ -106,11 +107,13 @@ func runBaselineClient(t *TestEnvironment) error {
t.RecordMessage("waiting for deal to be sealed")
waitDealSealed(t, ctx, client, deal)
t.D().ResettingHistogram("deal.sealed").Update(int64(time.Since(t1)))
carExport := true
t.RecordMessage("trying to retrieve %s", fcid)
retrieveData(t, ctx, err, client, fcid, carExport, data)
t.D().ResettingHistogram("deal.retrieved").Update(int64(time.Since(t1)))
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) {
t1 := time.Now()
offers, err := client.ClientFindData(ctx, fcid)
if err != nil {
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 {
panic("no offers")
@ -188,10 +196,12 @@ func retrieveData(t *TestEnvironment, ctx context.Context, err error, client api
Path: filepath.Join(rpath, "ret"),
IsCAR: carExport,
}
t1 = time.Now()
err = client.ClientRetrieve(ctx, offers[0].Order(caddr), ref)
if err != nil {
panic(err)
}
t.D().ResettingHistogram("retrieve-data").Update(int64(time.Since(t1)))
rdata, err := ioutil.ReadFile(filepath.Join(rpath, "ret"))
if err != nil {

View File

@ -6,6 +6,7 @@ import (
"math/rand"
"time"
"github.com/filecoin-project/lotus/build"
"github.com/testground/sdk-go/sync"
)
@ -28,6 +29,9 @@ func runMiner(t *TestEnvironment) error {
return err
}
t.RecordMessage("block delay: %v", build.BlockDelay)
t.D().Gauge("miner.block-delay").Update(build.BlockDelay)
ctx := context.Background()
clients := t.IntParam("clients")
@ -50,6 +54,8 @@ func runMiner(t *TestEnvironment) error {
time.Sleep(time.Duration(100 + rand.Intn(int(100*time.Millisecond))))
err := miner.MineOne(ctx, func(bool) {
t.D().Counter("miner.mine").Inc(1)
// after a block is mined
})
if err != nil {