Skip to content

Commit

Permalink
cmd/swarm: use resetting timer to measure fetch time (ethereum#18474)
Browse files Browse the repository at this point in the history
(cherry picked from commit a0b0db6)
  • Loading branch information
nonsense authored and dshulyak committed Mar 14, 2019
1 parent 06c3fe3 commit 953a4e8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cmd/swarm/swarm-smoke/upload_and_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,28 @@ func uploadAndSync(c *cli.Context) error {
for {
start := time.Now()
err := fetch(hash, endpoint, fhash, ruid)
fetchTime := time.Since(start)
if err != nil {
continue
}

metrics.GetOrRegisterMeter("upload-and-sync.single.fetch-time", nil).Mark(int64(fetchTime))
metrics.GetOrRegisterResettingTimer("upload-and-sync.single.fetch-time", nil).UpdateSince(start)
wg.Done()
return
}
}(endpoints[randIndex], ruid)
} else {
for _, endpoint := range endpoints {
for _, endpoint := range endpoints[1:] {
ruid := uuid.New()[:8]
wg.Add(1)
go func(endpoint string, ruid string) {
for {
start := time.Now()
err := fetch(hash, endpoint, fhash, ruid)
fetchTime := time.Since(start)
if err != nil {
continue
}

metrics.GetOrRegisterMeter("upload-and-sync.each.fetch-time", nil).Mark(int64(fetchTime))
metrics.GetOrRegisterResettingTimer("upload-and-sync.each.fetch-time", nil).UpdateSince(start)
wg.Done()
return
}
Expand Down

0 comments on commit 953a4e8

Please sign in to comment.