Skip to content

Commit

Permalink
fix: sampler duration tracks seconds (#3418)
Browse files Browse the repository at this point in the history
  • Loading branch information
istae authored Oct 11, 2022
1 parent c012d50 commit 13a4704
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/localstore/sampler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,17 @@ type sampleStat struct {
}

func (s *sampleStat) String() string {

seconds := int64(time.Second)

return fmt.Sprintf(
"Total: %d NotFound: %d New Ignored: %d Iteration Duration: %d secs GetDuration: %d secs HmacrDuration: %d",
s.TotalIterated.Load(),
s.NotFound.Load(),
s.NewIgnored.Load(),
s.IterationDuration.Load()/1000000,
s.GetDuration.Load()/1000000,
s.HmacrDuration.Load()/1000000,
s.IterationDuration.Load()/seconds,
s.GetDuration.Load()/seconds,
s.HmacrDuration.Load()/seconds,
)
}

Expand Down Expand Up @@ -92,7 +95,7 @@ func (db *DB) ReserveSample(
logger.Error(err, "sampler: failed iteration")
return err
}
stat.IterationDuration.Add(time.Since(iterationStart).Microseconds())
stat.IterationDuration.Add(time.Since(iterationStart).Nanoseconds())
return nil
})

Expand All @@ -106,7 +109,7 @@ func (db *DB) ReserveSample(
for addr := range addrChan {
getStart := time.Now()
chItem, err := db.get(ctx, storage.ModeGetSync, addr)
stat.GetDuration.Add(time.Since(getStart).Microseconds())
stat.GetDuration.Add(time.Since(getStart).Nanoseconds())
if err != nil {
stat.NotFound.Inc()
continue
Expand All @@ -126,7 +129,7 @@ func (db *DB) ReserveSample(
}
taddr := hmacr.Sum(nil)
hmacr.Reset()
stat.HmacrDuration.Add(time.Since(hmacrStart).Microseconds())
stat.HmacrDuration.Add(time.Since(hmacrStart).Nanoseconds())

select {
case sampleItemChan <- swarm.NewAddress(taddr):
Expand Down

0 comments on commit 13a4704

Please sign in to comment.