mirror of
https://github.com/wwhai/mqtt-benchmark.git
synced 2025-10-04 23:32:46 +08:00
Fixed formatting and linter errors
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
.DS_Store
|
||||
.idea
|
||||
.vscode
|
||||
mqtt-benchmark
|
||||
|
@@ -6,7 +6,7 @@ A simple MQTT (broker) benchmarking tool.
|
||||
Installation:
|
||||
|
||||
```sh
|
||||
go get github.com/krylovsk/mqtt-benchmark
|
||||
go install github.com/krylovsk/mqtt-benchmark
|
||||
```
|
||||
|
||||
The tool supports multiple concurrent clients, configurable message size, etc:
|
||||
|
@@ -57,7 +57,7 @@ func (c *Client) Run(res chan *RunResults) {
|
||||
}
|
||||
case <-donePub:
|
||||
// calculate results
|
||||
duration := time.Now().Sub(started)
|
||||
duration := time.Since(started)
|
||||
runResults.MsgTimeMin = stats.StatsMin(times)
|
||||
runResults.MsgTimeMax = stats.StatsMax(times)
|
||||
runResults.MsgTimeMean = stats.StatsMean(times)
|
||||
@@ -92,7 +92,6 @@ func (c *Client) genMessages(ch chan *Message, done chan bool) {
|
||||
|
||||
done <- true
|
||||
// log.Printf("CLIENT %v is done generating messages\n", c.ID)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) pubMessages(in, out chan *Message, doneGen, donePub chan bool) {
|
||||
|
5
main.go
5
main.go
@@ -126,7 +126,7 @@ func main() {
|
||||
for i := 0; i < *clients; i++ {
|
||||
results[i] = <-resCh
|
||||
}
|
||||
totalTime := time.Now().Sub(start)
|
||||
totalTime := time.Since(start)
|
||||
totals := calculateTotalResults(results, totalTime, *clients)
|
||||
|
||||
// print stats
|
||||
@@ -187,7 +187,7 @@ func printResults(results []*RunResults, totals *TotalResults, format string) {
|
||||
var out bytes.Buffer
|
||||
_ = json.Indent(&out, data, "", "\t")
|
||||
|
||||
fmt.Println(string(out.Bytes()))
|
||||
fmt.Println(out.String())
|
||||
default:
|
||||
for _, res := range results {
|
||||
fmt.Printf("======= CLIENT %d =======\n", res.ID)
|
||||
@@ -210,7 +210,6 @@ func printResults(results []*RunResults, totals *TotalResults, format string) {
|
||||
fmt.Printf("Average Bandwidth (msg/sec): %.3f\n", totals.AvgMsgsPerSec)
|
||||
fmt.Printf("Total Bandwidth (msg/sec): %.3f\n", totals.TotalMsgsPerSec)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func generateTLSConfig(certFile string, keyFile string) *tls.Config {
|
||||
|
Reference in New Issue
Block a user