-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2304460
commit 99a7deb
Showing
5 changed files
with
123 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
package bench | ||
|
||
import ( | ||
"text/template" | ||
) | ||
|
||
var tmpl = ` | ||
Status Codes: 200:541449 [code:count] | ||
Concurrency Level: .Concurrency | ||
Time taken for tests: .Time seconds | ||
Complete requests: .Total | ||
Failed requests: .Failed | ||
Total transferred: .Recv bytes | ||
HTML transferred: 0 bytes | ||
Requests per second: .Tps [#/sec] (mean) | ||
Time per request: .Mean [ms] (mean) | ||
Time per request: .AllMean [ms] (mean, across all concurrent requests) | ||
Transfer rate: .Kbs [Kbytes/sec] received | ||
Status Codes: {{range $code, $num := .StatusCodes}} {{$code}}:{{$num}} {{end}} [code:count] | ||
Concurrency Level: {{.Concurrency}} | ||
Time taken for tests: {{.Duration}} | ||
Complete requests: {{.CompleteRequest}} | ||
Failed requests: {{.Failed}} | ||
Total transferred: {{.TotalRead}} bytes | ||
Requests per second: {{.Tps}} [#/sec] (mean) | ||
Time per request: {{.Mean}} [ms] (mean) | ||
Time per request: {{.AllMean}} [ms] (mean, across all concurrent requests) | ||
Transfer rate: {{.Kbs}} [Kbytes/sec] received | ||
Percentage of the requests served within a certain time (ms) | ||
50% .Percentage55 ms | ||
66% .Percentage66 ms | ||
75% .Percentage75 ms | ||
80% .Percentage80 ms | ||
90% .Percentage90 ms | ||
95% .Percentage95 ms | ||
98% .Percentage98 ms | ||
99% .Percentage99 ms | ||
100% .Percentage100 ms | ||
50% {{.Percentage55}} | ||
66% {{.Percentage66}} | ||
75% {{.Percentage75}} | ||
80% {{.Percentage80}} | ||
90% {{.Percentage90}} | ||
95% {{.Percentage95}} | ||
98% {{.Percentage98}} | ||
99% {{.Percentage99}} | ||
100% {{.Percentage100}} | ||
` | ||
|
||
// 后面要加新的显示格式,只要加新的模版就行 | ||
func newTemplate() *template.Template { | ||
return template.Must(template.New("text").Parse(tmpl)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package bench | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"os" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func Test_Bench_newTemplate(t *testing.T) { | ||
tmpl := newTemplate() | ||
|
||
r := report{ | ||
Failed: 3, | ||
Percentage55: time.Second, | ||
Percentage66: 2 * time.Second, | ||
Percentage75: 3 * time.Second, | ||
Percentage80: 4 * time.Second, | ||
Percentage90: 5 * time.Second, | ||
Percentage95: 6 * time.Second, | ||
Percentage98: 7 * time.Second, | ||
Percentage99: 8 * time.Second, | ||
Percentage100: 9 * time.Second, | ||
StatusCodes: map[int]int{ | ||
200: 100, | ||
500: 3, | ||
}, | ||
} | ||
|
||
err := tmpl.Execute(os.Stdout, r) | ||
assert.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters