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
33a5a4bd
Commit
33a5a4bd
authored
Dec 17, 2017
by
htbegin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
histogram: add a test case for bucket_sort_fn
add a test case for bucket_sort_fn and show its use scenario as well
parent
a83e2781
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
tests/python/test_histogram.py
tests/python/test_histogram.py
+33
-0
No files found.
tests/python/test_histogram.py
View file @
33a5a4bd
...
...
@@ -72,6 +72,39 @@ int kprobe__finish_task_switch(struct pt_regs *ctx, struct task_struct *prev) {
b
[
"hist1"
].
print_log2_hist
()
b
.
cleanup
()
def
test_multiple_key
(
self
):
b
=
BPF
(
text
=
"""
#include <uapi/linux/ptrace.h>
#include <uapi/linux/fs.h>
struct hist_s_key {
u64 key_1;
u64 key_2;
};
struct hist_key {
struct hist_s_key s_key;
u64 slot;
};
BPF_HISTOGRAM(mk_hist, struct hist_key, 1024);
int kprobe__vfs_read(struct pt_regs *ctx, struct file *file,
char __user *buf, size_t count) {
struct hist_key key = {.slot = bpf_log2l(count)};
key.s_key.key_1 = (unsigned long)buf & 0x70;
key.s_key.key_2 = (unsigned long)buf & 0x7;
mk_hist.increment(key);
return 0;
}
"""
)
def
bucket_sort
(
buckets
):
buckets
.
sort
()
return
buckets
for
i
in
range
(
0
,
100
):
time
.
sleep
(
0.01
)
b
[
"mk_hist"
].
print_log2_hist
(
"size"
,
"k_1 & k_2"
,
section_print_fn
=
lambda
bucket
:
"%3d %d"
%
(
bucket
[
0
],
bucket
[
1
]),
bucket_fn
=
lambda
bucket
:
(
bucket
.
key_1
,
bucket
.
key_2
),
strip_leading_zero
=
True
,
bucket_sort_fn
=
bucket_sort
)
b
.
cleanup
()
if
__name__
==
"__main__"
:
main
()
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