Skip to content

Commit

Permalink
Don't use global ref in stats String method
Browse files Browse the repository at this point in the history
  • Loading branch information
tsenart committed Feb 25, 2014
1 parent 844be10 commit e1c4fab
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions stressdisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,23 @@ func NewStats() *Stats {
func (s *Stats) String() string {
s.lock.RLock()
defer s.lock.RUnlock()
dt := time.Now().Sub(stats.start)
dt := time.Now().Sub(s.start)
dt_seconds := dt.Seconds()
read_speed := 0.0
write_speed := 0.0
if dt > 0 {
read_speed = float64(stats.read) / MB / dt_seconds
write_speed = float64(stats.written) / MB / dt_seconds
read_speed = float64(s.read) / MB / dt_seconds
write_speed = float64(s.written) / MB / dt_seconds
}
return fmt.Sprintf(`
Bytes read: %10d MByte (%7.2f MByte/s)
Bytes written: %10d MByte (%7.2f MByte/s)
Errors: %10d
Elapsed time: %v
`,
stats.read/MB, read_speed,
stats.written/MB, write_speed,
stats.errors,
s.read/MB, read_speed,
s.written/MB, write_speed,
s.errors,
dt)
}

Expand Down

0 comments on commit e1c4fab

Please sign in to comment.