Skip to content

Commit

Permalink
cmd/swarm/swarm-smoke: use ResettingTimer instead of Counters for tim…
Browse files Browse the repository at this point in the history
…es (ethereum#18479)

(cherry picked from commit 5609577)
  • Loading branch information
holisticode authored and dshulyak committed Mar 14, 2019
1 parent 3a4f38a commit 8f6e211
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cmd/swarm/swarm-smoke/upload_and_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ func cliUploadAndSync(c *cli.Context) error {
func uploadAndSync(c *cli.Context) error {
defer func(now time.Time) {
totalTime := time.Since(now)

log.Info("total time", "time", totalTime, "kb", filesize)
metrics.GetOrRegisterCounter("upload-and-sync.total-time", nil).Inc(int64(totalTime))
metrics.GetOrRegisterResettingTimer("upload-and-sync.total-time", nil).Update(totalTime)
}(time.Now())

generateEndpoints(scheme, cluster, appName, from, to)
Expand All @@ -103,7 +102,7 @@ func uploadAndSync(c *cli.Context) error {
log.Error(err.Error())
return err
}
metrics.GetOrRegisterCounter("upload-and-sync.upload-time", nil).Inc(int64(time.Since(t1)))
metrics.GetOrRegisterResettingTimer("upload-and-sync.upload-time", nil).UpdateSince(t1)

fhash, err := digest(bytes.NewReader(randomBytes))
if err != nil {
Expand Down Expand Up @@ -166,8 +165,6 @@ func fetch(hash string, endpoint string, original []byte, ruid string) error {
ctx, sp := spancontext.StartSpan(context.Background(), "upload-and-sync.fetch")
defer sp.Finish()

log.Trace("sleeping", "ruid", ruid)
time.Sleep(3 * time.Second)
log.Trace("http get request", "ruid", ruid, "api", endpoint, "hash", hash)

var tn time.Time
Expand Down

0 comments on commit 8f6e211

Please sign in to comment.