Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: unnecessary use of fmt.Sprintf #1705

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion hrp/pkg/boomer/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (r *runner) reportTestResult() {
}
duration := time.Duration(entryTotalOutput.LastRequestTimestamp-entryTotalOutput.StartTime) * time.Millisecond
currentTime := time.Now()
println(fmt.Sprint("=========================================== Statistics Summary =========================================="))
println("=========================================== Statistics Summary ==========================================")
println(fmt.Sprintf("Current time: %s, Users: %v, Duration: %v, Accumulated Transactions: %d Passed, %d Failed",
currentTime.Format("2006/01/02 15:04:05"), r.controller.getCurrentClientsNum(), duration, r.stats.transactionPassed, r.stats.transactionFailed))
table := tablewriter.NewWriter(os.Stdout)
Expand Down
12 changes: 6 additions & 6 deletions hrp/pkg/boomer/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ func GetCurrentPidCPUUsage() float64 {
currentPid := os.Getpid()
p, err := process.NewProcess(int32(currentPid))
if err != nil {
log.Error().Err(err).Msg(fmt.Sprintf("failed to get CPU percent\n"))
log.Error().Err(err).Msg("failed to get CPU percent\n")
return 0.0
}
percent, err := p.CPUPercent()
if err != nil {
log.Error().Err(err).Msg(fmt.Sprintf("failed to get CPU percent\n"))
log.Error().Err(err).Msg("failed to get CPU percent\n")
return 0.0
}
return percent
Expand All @@ -110,12 +110,12 @@ func GetCurrentPidCPUPercent() float64 {
currentPid := os.Getpid()
p, err := process.NewProcess(int32(currentPid))
if err != nil {
log.Error().Err(err).Msg(fmt.Sprintf("failed to get CPU percent\n"))
log.Error().Err(err).Msg("failed to get CPU percent\n")
return 0.0
}
percent, err := p.Percent(time.Second)
if err != nil {
log.Error().Err(err).Msg(fmt.Sprintf("failed to get CPU percent\n"))
log.Error().Err(err).Msg("failed to get CPU percent\n")
return 0.0
}
return percent
Expand All @@ -138,12 +138,12 @@ func GetCurrentPidMemoryUsage() float64 {
currentPid := os.Getpid()
p, err := process.NewProcess(int32(currentPid))
if err != nil {
log.Error().Err(err).Msg(fmt.Sprintf("failed to get CPU percent\n"))
log.Error().Err(err).Msg("failed to get CPU percent\n")
return 0.0
}
percent, err := p.MemoryPercent()
if err != nil {
log.Error().Err(err).Msg(fmt.Sprintf("failed to get CPU percent\n"))
log.Error().Err(err).Msg("failed to get CPU percent\n")
return 0.0
}
return float64(percent)
Expand Down