Skip to content

Commit

Permalink
add options to html format output
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed Aug 10, 2018
1 parent 702c3b9 commit b5d9c80
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 71 deletions.
84 changes: 53 additions & 31 deletions printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,19 @@ var tmplFuncMap = template.FuncMap{
"formatPercent": formatPercent,
}

func jsonify(v interface{}) string {
func jsonify(v interface{}, pretty bool) string {
d, _ := json.Marshal(v)
return string(d)
if !pretty {
return string(d)
}

var out bytes.Buffer
err := json.Indent(&out, d, "", " ")
if err != nil {
return string(d)
}

return string(out.Bytes())
}

func formatMilli(duration float64) string {
Expand Down Expand Up @@ -172,7 +182,7 @@ duration (ms),status,error{{ range $i, $v := .Details }}
<section class="section">
<div class="container">
<nav class="breadcrumb has-bullet-separator" aria-label="breadcrumbs">
<nav class="breadcrumb has-bullet-separator" aria-label="breadcrumbs">
<ul>
<li>
<a href="#summary">
Expand Down Expand Up @@ -239,34 +249,46 @@ duration (ms),status,error{{ range $i, $v := .Details }}
<table class="table">
<tbody>
<tr>
<th>Count</th>
<td>{{ .Count }}</td>
</tr>
<tr>
<th>Total</th>
<td>{{ formatMilli .Total.Seconds }} ms</td>
</tr>
<tr>
<th>Slowest</th>
<td>{{ formatMilli .Slowest.Seconds }} ms</td>
</tr>
<tr>
<th>Fastest</th>
<td>{{ formatMilli .Fastest.Seconds }} ms</td>
</tr>
<tr>
<th>Average</th>
<td>{{ formatMilli .Average.Seconds }} ms</td>
</tr>
<tr>
<th>Requests / sec</th>
<td>{{ formatSeconds .Rps }}</td>
</tr>
</tbody>
</table>
<th>Count</th>
<td>{{ .Count }}</td>
</tr>
<tr>
<th>Total</th>
<td>{{ formatMilli .Total.Seconds }} ms</td>
</tr>
<tr>
<th>Slowest</th>
<td>{{ formatMilli .Slowest.Seconds }} ms</td>
</tr>
<tr>
<th>Fastest</th>
<td>{{ formatMilli .Fastest.Seconds }} ms</td>
</tr>
<tr>
<th>Average</th>
<td>{{ formatMilli .Average.Seconds }} ms</td>
</tr>
<tr>
<th>Requests / sec</th>
<td>{{ formatSeconds .Rps }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="column">
<div class="content">
<span class="title is-5">
<strong>Options</strong>
</span>
<article class="message">
<div class="message-body">
<pre style="background-color: transparent;">{{ jsonify .Options true }}</pre>
</div>
</article>
</div>
</div>
</div>
</div>
<br />
Expand Down Expand Up @@ -406,7 +428,7 @@ duration (ms),status,error{{ range $i, $v := .Details }}
const count = {{ .Count }};
const rawData = {{ jsonify .Details }};
const rawData = {{ jsonify .Details false }};
const data = [
{{ range .Histogram }}
Expand Down
28 changes: 14 additions & 14 deletions testdata/localhost.crt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
-----BEGIN CERTIFICATE-----
MIIC5TCCAc2gAwIBAgIJAPMeFjozN41RMA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNV
BAMMCWxvY2FsaG9zdDAeFw0xODA3MTAyMzMyNTNaFw0xODA4MDkyMzMyNTNaMBQx
MIIC5TCCAc2gAwIBAgIJALm/8UVJ0qNPMA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNV
BAMMCWxvY2FsaG9zdDAeFw0xODA4MTAwMDIzMTJaFw0xODA5MDkwMDIzMTJaMBQx
EjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
ggEBALVtHZE+p5r4QlS9jib5AHHlt3Yyr+ASKhkNUX+tNHZSjy1kkrQmuyFMA71m
Hn0D0ASBG7kEqfPnmLY+VSurte43LZOgEWH0tUm4cCSfwKaaHG3yr5RPwc/rhI3U
TIgSZWpitafzYbaqU1dEsBbHiYPOnrZmRYmXefsPE3Bob4/c9lf+V1UjGE/v1AWa
HCaJPId1xn22rRSQeoZS6zNx1ICi2b2Q2S1Geb/a24E06OgaoJExMSfNJP04oECt
uVu1pnNdpfBA8exRB2JCy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M20qoEJ98BWkO1spu7qUvBjz
Gp/vn0qAzsY2k8AYzds1dgGOeRvpDCpRrCcRbL2nqrr4SUv7rP+wIh+FZMDhr9nW
3Mu4ZjdkizG+LxHtqhczRb01ZhWCkkNJ01QOWM5dsVj5ZIHwRk5PV6Unh9FtIRvr
E2Dllysnw674/peAs93AqBJ4MAEAtmXQXQ==
-----END CERTIFICATE-----
52 changes: 26 additions & 26 deletions testdata/localhost.key
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC1bR2RPqea+EJU
vY4m+QBx5bd2Mq/gEioZDVF/rTR2Uo8tZJK0JrshTAO9Zh59A9AEgRu5BKnz55i2
PlUrq7XuNy2ToBFh9LVJuHAkn8Cmmhxt8q+UT8HP64SN1EyIEmVqYrWn82G2qlNX
RLAWx4mDzp62ZkWJl3n7DxNwaG+P3PZX/ldVIxhP79QFmhwmiTyHdcZ9tq0UkHqG
UuszcdSAotm9kNktRnm/2tuBNOjoGqCRMTEnzST9OKBArblbtaZzXaXwQPHsUQdi
QssVZ0WZyvsJmgA5rK76T+2++99XZnTcu87W98F213sKWk2Nd2RH0rixa3fJbAdJ
F3yWIqd3AgMBAAECggEBAIS+LIcMD7fcczPraWnsgD3VtRE/bt2EjNa9nubLBPqZ
13aAArLbL8niA059vEr+EiJpkK4j0nHJ/ztAijKktT1xk+BSmsVQNaCV2T+Cv4Nm
eOydR4g9fvIxQVBAiCp7Q0a+qGkVM2ZiYw4UDL7uChitggS0+aX9dduSoUd6sj3Q
Uk6CT4BUIjB1+yAhLY53NgGqX/iAkbt84+JWug3ELZ3lrcSOe4NdBEsN1PNrbKiV
BzQ4dQBJF9O8pz10HYV/gKoLHxmbII067ERyfDmliTJONy/xUx1zxF37gMg32yTz
BsILDmwGB3unTAjB8W6nNkEnLMmlkZs84R/Ztrr9S2ECgYEA7q3qvSSwY+fCef2q
geM2LC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Fhx8rISyI5LF2kCgYEA
wmGWxLtOWdAE9M9up4jahHb6KTfidugTv0E76xTacoTa9e4PtDGSUkXeuCJz4Z4a
EO/29jV+icbwHek36KHMQcW0afMSOSbsxqBGESLfJ4qcRqKDwIEb+IYUe4RiiC+z
4wGQCit76jPNcZf8kUXC0z8Yev/xTGw5ofmjMMDEIjUCgYB8H0VH5RF+2hQIkowv
mCr0wDhWvLntjFKe/4Xx1hjxSd4uzPsj6qVbjmjHuAnA+VN3YBqO/iXOxLGlJEfb
zycUdntnTkhILj1l8GmHZV3sop4hUbnW8ziGLxmMXAPVqnPGigscBkfHS80oYn8s
E6Jfc1lF95dPXTUHv395sKmMsw==
-----END PRIVATE KEY-----

0 comments on commit b5d9c80

Please sign in to comment.