Commit 0c89b18e authored by Brendan Gregg's avatar Brendan Gregg Committed by GitHub

Merge pull request #111 from iovisor/truncate-hist

truncate zero range on hist
parents 56eb2e63 683175ec
......@@ -1502,12 +1502,9 @@ Attaching 1 probe...
^C
@bytes[snmp-pass]:
[0, 1] 0 | |
[2, 4) 0 | |
[4, 8) 6 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
@bytes[ls]:
[0, 1] 0 | |
[2, 4) 9 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
@bytes[snmpd]:
......@@ -1536,18 +1533,11 @@ Attaching 1 probe...
^C
@bytes:
(...,0] 0 | |
[0, 1000) 480 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[1000, 2000) 49 |@@@@@ |
[2000, 3000) 12 |@ |
[3000, 4000) 39 |@@@@ |
[4000, 5000) 267 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@ |
[5000, 6000) 0 | |
[6000, 7000) 0 | |
[7000, 8000) 0 | |
[8000, 9000) 0 | |
[9000, 10000) 0 | |
[10000,...) 0 | |
```
## 10. `print()`: Print Map
......
......@@ -933,14 +933,18 @@ int BPFtrace::print_map_stats(IMap &map)
int BPFtrace::print_hist(const std::vector<uint64_t> &values, uint32_t div) const
{
int min_index = -1;
int max_index = -1;
int max_value = 0;
for (size_t i = 0; i < values.size(); i++)
{
int v = values.at(i);
if (v != 0)
if (v > 0) {
if (min_index == -1)
min_index = i;
max_index = i;
}
if (v > max_value)
max_value = v;
}
......@@ -948,7 +952,7 @@ int BPFtrace::print_hist(const std::vector<uint64_t> &values, uint32_t div) cons
if (max_index == -1)
return 0;
for (int i = 0; i <= max_index; i++)
for (int i = min_index; i <= max_index; i++)
{
std::ostringstream header;
if (i == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment