Skip to content

Commit 775a7e3

Browse files
committed
simplify
1 parent ae7dc04 commit 775a7e3

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

operation.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ func NewOperation(ctx context.Context, reader bool) (op *Operation) {
2828
}
2929

3030
func (op *Operation) run(ctx context.Context, ch chan<- struct{}) {
31+
defer close(ch)
3132
seccount := 0
3233
now := time.Now()
33-
defer close(ch)
3434

3535
for {
3636
if elapsed := time.Since(now); elapsed > 0 {
@@ -55,7 +55,8 @@ func (op *Operation) run(ctx context.Context, ch chan<- struct{}) {
5555

5656
time.Sleep(interval - time.Since(now))
5757
seccount++
58-
if seccount%secparts == 0 {
58+
if seccount >= secparts {
59+
seccount = 0
5960
op.Rate.Store(op.count.Swap(0))
6061
}
6162
}

0 commit comments

Comments
 (0)