From a0b0db63055e1dd350215f9fe04b0abf19f3488a Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 18 Jan 2019 13:27:27 +0100 Subject: [PATCH] cmd/swarm: use resetting timer to measure fetch time (#18474) --- cmd/swarm/swarm-smoke/upload_and_sync.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmd/swarm/swarm-smoke/upload_and_sync.go b/cmd/swarm/swarm-smoke/upload_and_sync.go index d605f79a3a49..728975c36bd3 100644 --- a/cmd/swarm/swarm-smoke/upload_and_sync.go +++ b/cmd/swarm/swarm-smoke/upload_and_sync.go @@ -125,30 +125,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 }