Skip to content

Commit 754136a

Browse files
committed
result improvment
1 parent 1ad24de commit 754136a

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

README.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ SMTP Performance Test Tool
55

66
![Bomberman Logo](https://github.com/c1982/bomberman/blob/master/logo.jpg?raw=true)
77

8-
98
## Installation
109

1110
bomberman requires Go 1.11 or later.
@@ -16,7 +15,6 @@ $ go get github.com/c1982/bomberman
1615

1716
or
1817

19-
2018
[download](https://github.com/c1982/bomberman/releases)
2119

2220
## Flags
@@ -27,16 +25,15 @@ or
2725
| from | From email address |
2826
| to | To email address|
2927
| subject | Email subject text |
30-
| size | Set email size Kilobytes (1024 Kilobyte = 1Mbyte) |
28+
| size | Set email size Kilobytes (1024 Kilobyte = 1Mbyte). Default: 5Kb |
3129
| helo | SMTP client helo name. Default: mail.server.com |
3230
| count | Email message count. Default: 10|
33-
| workers | Thread workers for SMTP client. Default: 100 |
34-
| jobs | Job queue lenght in workers. Default: 50 |
31+
| workers | Thread workers for SMTP client. Default: 10 |
32+
| jobs | Job queue lenght in workers. Default: 10 |
3533
| outbound | Outbound IP address for SMTP client |
3634
| showerror | Print SMTP errors |
3735
| balance | Tool is use all IP address for outbound ip with sequental balance. Defalut: false |
3836

39-
4037
## Server Configuration Checklist
4138

4239
* Set SPF value in from email address domain.
@@ -45,7 +42,7 @@ or
4542

4643
## Usage
4744

48-
Send 10 email to mail.server.com:25 50 workers
45+
Send 50 email to mail.server.com:25 50 workers
4946

5047
```
5148
./bomberman -host=mail.server.com:25 [email protected] [email protected] -workers=50 -jobs=50 -count=50 -size=75 -balance
@@ -72,7 +69,7 @@ Source IP Stats:
7269
7370
Destination IP Stats:
7471
75-
5.4.0.248:25 : 856
72+
5.4.0.248:25 : 856
7673
7774
SMTP Commands:
7875
@@ -81,7 +78,7 @@ DIAL (1022) : min. 27.323µs, max. 6.000565014s, med. 1.511920428s
8178
HELO (854) : min. 34.061919ms, max. 3.80865823s, med. 343.306129ms
8279
MAIL (854) : min. 42.455906ms, max. 6.150506182s, med. 943.313477ms
8380
RCPT (854) : min. 34.972014ms, max. 3.151397545s, med. 497.683671ms
84-
SUCCESS (854) : min. 1.480909163s, max. 37.223728269s, med. 15.673002296s
81+
SUCCESS (854) : min. 1.480909163s, max. 37.223728269s, med. 15.673002296s
8582
TOUCH (854) : min. 112.109537ms, max. 17.759899662s, med. 3.985871341s
8683
```
8784

main.go

+9-13
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ const (
3737
metricTemplate = `` +
3838
`Bomberman - SMTP Performance Test Tool` + "\n" +
3939
`--------------------------------------` + "\n" +
40-
`Message Count : %d` + "\n" +
41-
`Message Size : %dK` + "\n" +
40+
`Count : %d` + "\n" +
4241
`Error : %d` + "\n" +
42+
`Size : %dK` + "\n" +
4343
`Start : %v` + "\n" +
4444
`End : %v` + "\n" +
4545
`Time : %v` + "\n"
@@ -87,7 +87,7 @@ func usage() {
8787
fmt.Fprintln(os.Stderr, "OPTIONS:")
8888
flag.PrintDefaults()
8989
fmt.Fprintln(os.Stderr, "USAGE:")
90-
fmt.Fprintln(os.Stderr, "./bomberman -host=mail.server.com:25 [email protected] [email protected] -workers=100 -jobs=100 -count=100 -outbound=YOUR_PUBLIC_IP -helo=mydomain.com -subject=\"Test Email\"")
90+
fmt.Fprintln(os.Stderr, "./bomberman -host=mail.server.com:25 [email protected] [email protected] -workers=100 -jobs=100 -count=100 -helo=mydomain.com -balance -size=2")
9191
fmt.Fprintln(os.Stderr, "")
9292
}
9393

@@ -123,12 +123,10 @@ func printResults(balanced bool, startTime, endtime time.Time) {
123123
}
124124

125125
if len(metric.DstIPStats) > 1 {
126-
127126
fmt.Println("")
128127
fmt.Println("Destination IP Stats:")
129128
fmt.Println("")
130129
printSlice(metric.DstIPStats, "%s\t: %d\n")
131-
132130
}
133131

134132
fmt.Println("")
@@ -143,6 +141,7 @@ func printResults(balanced bool, startTime, endtime time.Time) {
143141
cnt := countMetric(m, metric.Durations)
144142
fmt.Printf("%s (%d)\t: min. %v, max. %v, med. %v\n", m, cnt, min, max, me)
145143
}
144+
fmt.Println("")
146145
}
147146

148147
func start() {
@@ -187,9 +186,11 @@ func start() {
187186
metric.ErrorCnt++
188187
}
189188

190-
metric.DstIPStats = append(metric.DstIPStats, remoteip)
191-
metric.Durations = append(metric.Durations, durs)
189+
if remoteip != "" {
190+
metric.DstIPStats = append(metric.DstIPStats, remoteip)
191+
}
192192

193+
metric.Durations = append(metric.Durations, durs)
193194
}
194195
}
195196

@@ -267,12 +268,7 @@ func sendMail(outbound, smtpServer, from, to, subject, body, helo string) (metri
267268

268269
dataTime := time.Now()
269270

270-
msg = ""
271-
msg += fmt.Sprintf("from: <%s>\r\n", from)
272-
msg += fmt.Sprintf("to: %s\r\n", to)
273-
msg += fmt.Sprintf("Subject: %s\r\n", subject)
274-
msg += fmt.Sprintf("\r\n%s", body)
275-
271+
msg = fmt.Sprintf(bodyTemplate, from, to, subject, body)
276272
wc, err = c.Data()
277273

278274
if err != nil {

0 commit comments

Comments
 (0)