Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bpftrace
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
bpftrace
Commits
1fc0c1f7
Commit
1fc0c1f7
authored
Sep 05, 2018
by
williangaspar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lhist human readable fixes:
https://github.com/iovisor/bpftrace/issues/2
parent
e35d318c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
6 deletions
+33
-6
src/bpftrace.cpp
src/bpftrace.cpp
+32
-6
src/bpftrace.h
src/bpftrace.h
+1
-0
No files found.
src/bpftrace.cpp
View file @
1fc0c1f7
...
...
@@ -891,7 +891,7 @@ int BPFtrace::print_hist(const std::vector<uint64_t> &values, uint32_t div) cons
return
0
;
}
int
BPFtrace
::
print_lhist
(
const
std
::
vector
<
uint64_t
>
&
values
,
int
min
,
int
max
,
int
step
)
const
int
BPFtrace
::
print_lhist
(
const
std
::
vector
<
uint64_t
>
&
values
,
int
min
,
int
max
,
int
step
)
const
{
int
max_index
=
-
1
;
int
max_value
=
0
;
...
...
@@ -910,7 +910,7 @@ int BPFtrace::print_lhist(const std::vector<uint64_t> &values, int min, int max,
return
0
;
std
::
ostringstream
lt
;
lt
<<
"(...,"
<<
min
<<
"]"
;
lt
<<
"(...,"
<<
lhist_index_label
(
min
)
<<
"]"
;
std
::
ostringstream
gt
;
// trim empty values
...
...
@@ -937,12 +937,12 @@ int BPFtrace::print_lhist(const std::vector<uint64_t> &values, int min, int max,
int
bar_width
=
values
.
at
(
i
)
/
(
float
)
max_value
*
max_width
;
std
::
ostringstream
header
;
if
(
i
==
0
)
{
header
<<
"(...,"
<<
min
<<
"]"
;
header
<<
"(...,"
<<
lhist_index_label
(
min
)
<<
"]"
;
}
else
if
(
i
==
(
buckets
+
1
))
{
header
<<
"["
<<
max
<<
",...)"
;
header
<<
"["
<<
lhist_index_label
(
max
)
<<
",...)"
;
}
else
{
header
<<
"["
<<
(
i
-
1
)
*
step
+
min
;
header
<<
", "
<<
i
*
step
+
min
<<
")"
;
header
<<
"["
<<
lhist_index_label
((
i
-
1
)
*
step
+
min
)
;
header
<<
", "
<<
lhist_index_label
(
i
*
step
+
min
)
<<
")"
;
}
std
::
string
bar
(
bar_width
,
'@'
);
...
...
@@ -987,6 +987,32 @@ std::string BPFtrace::hist_index_label(int power)
return
label
.
str
();
}
std
::
string
BPFtrace
::
lhist_index_label
(
int
number
)
{
int
kilo
=
1024
;
int
mega
=
1048576
;
std
::
ostringstream
label
;
if
(
number
<
kilo
)
{
label
<<
number
;
}
else
if
(
number
%
mega
==
0
)
{
label
<<
number
/
mega
<<
'm'
;
}
else
if
(
number
%
kilo
==
0
)
{
label
<<
number
/
kilo
<<
'k'
;
}
else
{
label
<<
number
;
}
return
label
.
str
();
}
uint64_t
BPFtrace
::
reduce_value
(
const
std
::
vector
<
uint8_t
>
&
value
,
int
ncpus
)
{
uint64_t
sum
=
0
;
...
...
src/bpftrace.h
View file @
1fc0c1f7
...
...
@@ -82,6 +82,7 @@ private:
static
uint64_t
min_value
(
const
std
::
vector
<
uint8_t
>
&
value
,
int
ncpus
);
static
uint64_t
max_value
(
const
std
::
vector
<
uint8_t
>
&
value
,
int
ncpus
);
static
std
::
string
hist_index_label
(
int
power
);
static
std
::
string
lhist_index_label
(
int
number
);
std
::
vector
<
uint8_t
>
find_empty_key
(
IMap
&
map
,
size_t
size
)
const
;
};
...
...
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