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

Supports to strip leading zero on print_log2_hist function #1226

Merged
merged 10 commits into from
Jun 29, 2017
Prev Previous commit
Next Next commit
Add new argument for print_log2_hist function for stripping left zeros
  • Loading branch information
Taekho Nam committed Jun 23, 2017
commit 582b4969910b7fb52cfb4d7c6f773135f7c2e9c6
10 changes: 6 additions & 4 deletions src/python/bcc/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def _stars(val, val_max, width):
return text


def _print_log2_hist(vals, val_type, strip_leading_zero=None):
def _print_log2_hist(vals, val_type, strip_leading_zero):
global stars_max
log2_dist_max = 64
idx_max = -1
Expand Down Expand Up @@ -87,7 +87,7 @@ def _print_log2_hist(vals, val_type, strip_leading_zero=None):
if val:
print(body % (low, high, val, stars,
_stars(val, val_max, stars)))
strip_leading_zero = None
strip_leading_zero = False
else:
print(body % (low, high, val, stars,
_stars(val, val_max, stars)))
Expand Down Expand Up @@ -300,8 +300,10 @@ def print_log2_hist(self, val_type="value", section_header="Bucket ptr",
If section_print_fn is not None, it will be passed the bucket value
to format into a string as it sees fit. If bucket_fn is not None,
it will be used to produce a bucket value for the histogram keys.
The maximum index allowed is log2_index_max (65), which will
accomodate any 64-bit integer in the histogram.
If the value of strip_leading_zero is not False, prints a histogram
that is omitted leading zeros from the beginning.The maximum index
allowed is log2_index_max (65), which will accomodate any 64-bit
integer in the histogram.
"""
if isinstance(self.Key(), ct.Structure):
tmp = {}
Expand Down