Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
a8fbb90f
Commit
a8fbb90f
authored
Sep 25, 2015
by
Brenden Blanco
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #252 from iovisor/bblanco_dev
Add custom formatter function to print_log2_hist
parents
ebc8e7e7
6df2b0ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
19 deletions
+13
-19
src/python/bcc/__init__.py
src/python/bcc/__init__.py
+12
-4
tools/funclatency
tools/funclatency
+1
-15
No files found.
src/python/bcc/__init__.py
View file @
a8fbb90f
...
...
@@ -238,13 +238,17 @@ class BPF(object):
text
=
text
[:
-
1
]
+
"+"
return
text
def
print_log2_hist
(
self
,
val_type
=
"value"
,
bucket_type
=
"ptr"
):
"""print_log2_hist(val_type="value", bucket_type="ptr")
def
print_log2_hist
(
self
,
val_type
=
"value"
,
section_header
=
"Bucket ptr"
,
section_print_fn
=
None
):
"""print_log2_hist(val_type="value", section_header="Bucket ptr",
section_print_fn=None)
Prints a table as a log2 histogram. The table must be stored as
log2. The val_type argument is optional, and is a column header.
If the histogram has a secondary key, multiple tables will print
and bucket_type can be used as a header description for each.
and section_header can be used as a header description for each.
If section_print_fn is not None, it will be passed the bucket value
to format into a string as it sees fit.
"""
if
isinstance
(
self
.
Key
(),
ct
.
Structure
):
tmp
=
{}
...
...
@@ -256,7 +260,11 @@ class BPF(object):
slot
=
getattr
(
k
,
f2
)
vals
[
slot
]
=
v
.
value
for
bucket
,
vals
in
tmp
.
items
():
print
(
"
\
n
Bucket %s = %r"
%
(
bucket_type
,
bucket
))
if
section_print_fn
:
print
(
"
\
n
%s = %s"
%
(
section_header
,
section_print_fn
(
bucket
)))
else
:
print
(
"
\
n
%s = %r"
%
(
section_header
,
bucket
))
self
.
_print_log2_hist
(
vals
,
val_type
,
0
)
else
:
vals
=
[
0
]
*
65
...
...
tools/funclatency
View file @
a8fbb90f
...
...
@@ -161,20 +161,6 @@ if matched == 0:
print
(
"Tracing %d functions for
\
"
%s
\
"
... Hit Ctrl-C to end."
%
(
matched
/
2
,
args
.
pattern
))
# custom output (from __init__.py)
def
print_log2_hist_byfunc
(
self
,
val_type
=
"value"
):
tmp
=
{}
f1
=
self
.
Key
.
_fields_
[
0
][
0
]
f2
=
self
.
Key
.
_fields_
[
1
][
0
]
for
k
,
v
in
self
.
items
():
bucket
=
getattr
(
k
,
f1
)
vals
=
tmp
[
bucket
]
=
tmp
.
get
(
bucket
,
[
0
]
*
65
)
slot
=
getattr
(
k
,
f2
)
vals
[
slot
]
=
v
.
value
for
bucket
,
vals
in
tmp
.
items
():
print
(
"
\
n
Function = %s"
%
BPF
.
ksym
(
bucket
))
self
.
_print_log2_hist
(
vals
,
val_type
,
0
)
# output
exiting
=
0
if
args
.
interval
else
1
dist
=
b
.
get_table
(
"dist"
)
...
...
@@ -191,7 +177,7 @@ while (1):
print
(
"%-8s
\
n
"
%
strftime
(
"%H:%M:%S"
),
end
=
""
)
if
args
.
function
:
print_log2_hist_byfunc
(
dist
,
label
)
dist
.
print_log2_hist
(
label
,
"Function"
,
BPF
.
ksym
)
else
:
dist
.
print_log2_hist
(
label
)
dist
.
clear
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment