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

Cli percentile column fit #354

Merged
merged 4 commits into from
Jun 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion source/client/output_formatter_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ std::string ConsoleOutputFormatterImpl::formatProto(const nighthawk::client::Out
<< std::endl;
header_written = true;
}
ss << fmt::format(" {:<{}}{:<{}}{:<{}}", p, 12, percentile.count(), 12,
auto s_percentile = fmt::format("{:.{}g}", p, 8);
ss << fmt::format(" {:<{}}{:<{}}{:<{}}", s_percentile, 12, percentile.count(), 12,
percentile.has_duration()
? formatProtoDuration(percentile.duration())
: fmt::format("{}", static_cast<int64_t>(percentile.raw_value())),
Expand Down
2 changes: 2 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ envoy_cc_test(
"test_data/output_formatter.medium.proto.gold",
"test_data/output_formatter.txt.gold",
"test_data/output_formatter.yaml.gold",
"test_data/percentile-column-overflow.json",
"test_data/percentile-column-overflow.txt.gold",
],
repository = "@envoy",
deps = [
Expand Down
7 changes: 7 additions & 0 deletions test/output_formatter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ TEST_F(MediumOutputCollectorTest, FortioFormatter) {
"test/test_data/output_formatter.medium.fortio.gold");
}

TEST_F(MediumOutputCollectorTest, ConsoleOutputFormatter) {
const auto input_proto = loadProtoFromFile("test/test_data/percentile-column-overflow.json");
ConsoleOutputFormatterImpl formatter;
expectEqualToGoldFile(formatter.formatProto(input_proto),
"test/test_data/percentile-column-overflow.txt.gold");
}

class StatidToNameTest : public Test {};

TEST_F(StatidToNameTest, TestTranslations) {
Expand Down
20 changes: 20 additions & 0 deletions test/test_data/percentile-column-overflow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"results": [
{
"name": "global",
"statistics": [
{
"count": "1",
"id": "foo",
"percentiles": [
{
"percentile": 0.99931640625,
"count": "1",
"duration": "0s"
}
]
}
]
}
]
}
10 changes: 10 additions & 0 deletions test/test_data/percentile-column-overflow.txt.gold
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Nighthawk - A layer 7 protocol benchmarking tool.

foo (1 samples)
min: 0 | mean: 0.0 | max: 0 | pstdev: 0.0

Percentile Count Value
0.99931641 1 0s 000ms 000us

Counter Value Per second