Skip to content

Commit

Permalink
Merge branch 'fat'
Browse files Browse the repository at this point in the history
去掉线程随机延迟,使用命令行指定参数作为延迟时间
  • Loading branch information
JKme committed Sep 5, 2022
2 parents cf20983 + 36f2f61 commit 8e9f7a9
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions core/options.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package core

import (
"cube/gologger"
"fmt"
"math/rand"
"strconv"
"time"
)
import "cube/gologger"

type GlobalOption struct {
Threads int
Expand All @@ -21,11 +15,13 @@ func NewGlobalOptions() *GlobalOption {
}

func RandomDelay(float float64) float64 {
r := rand.New(rand.NewSource(time.Now().Unix()))
r1 := r.Float64() * float
r1, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", r1), 64) //保留两位小数点
if r1 > 0 {
gologger.Debugf("thread is going to sleep %v second", r1)
}
return r1
//r := rand.New(rand.NewSource(time.Now().Unix()))
//r1 := r.Float64() * float
//r1, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", r1), 64) //保留两位小数点
//if r1 > 0 {
// gologger.Debugf("thread is going to sleep %v second", r1)
//}
//return r1
gologger.Debugf("thread is going to sleep %v second", float)
return float
}

0 comments on commit 8e9f7a9

Please sign in to comment.