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
dcd9e625
Commit
dcd9e625
authored
Jun 05, 2017
by
Alastair Robertson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify code to generate histogram labels
parent
c203e541
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
41 deletions
+38
-41
src/bpftrace.cpp
src/bpftrace.cpp
+37
-41
src/bpftrace.h
src/bpftrace.h
+1
-0
No files found.
src/bpftrace.cpp
View file @
dcd9e625
...
...
@@ -176,54 +176,19 @@ int BPFtrace::print_quantize(std::vector<uint64_t> values)
if
(
max_index
==
-
1
)
return
0
;
std
::
cout
<<
std
::
setw
(
16
)
<<
std
::
left
<<
"[0, 1]"
<<
std
::
setw
(
8
)
<<
std
::
right
<<
values
.
at
(
0
)
<<
" |"
<<
std
::
endl
;
for
(
int
i
=
1
;
i
<=
max_index
;
i
++
)
for
(
int
i
=
0
;
i
<=
max_index
;
i
++
)
{
int
power1
=
i
,
power2
;
char
suffix1
=
'\0'
,
suffix2
=
'\0'
;
if
(
power1
>=
30
)
{
suffix1
=
'G'
;
power1
-=
30
;
}
else
if
(
power1
>=
20
)
{
suffix1
=
'M'
;
if
(
power1
==
29
)
suffix2
=
'G'
;
power1
-=
20
;
}
else
if
(
power1
>=
10
)
{
suffix1
=
'k'
;
if
(
power1
==
19
)
suffix2
=
'M'
;
power1
-=
10
;
}
if
(
!
suffix2
)
std
::
ostringstream
header
;
if
(
i
==
0
)
{
suffix2
=
suffix1
;
power2
=
power1
;
header
<<
"[0, 1]"
;
}
else
{
power2
=
power1
-
10
;
header
<<
"["
<<
quantize_index_label
(
i
);
header
<<
", "
<<
quantize_index_label
(
i
+
1
)
<<
")"
;
}
int
start
=
1
<<
power1
;
int
end
=
(
1
<<
(
power2
+
1
));
std
::
ostringstream
header
;
header
<<
"["
<<
start
;
if
(
suffix1
)
header
<<
suffix1
;
header
<<
", "
<<
end
;
if
(
suffix2
)
header
<<
suffix2
;
header
<<
")"
;
int
max_width
=
52
;
int
bar_width
=
values
.
at
(
i
)
/
(
float
)
max_value
*
max_width
;
std
::
string
bar
(
bar_width
,
'@'
);
...
...
@@ -237,4 +202,35 @@ int BPFtrace::print_quantize(std::vector<uint64_t> values)
return
0
;
}
std
::
string
BPFtrace
::
quantize_index_label
(
int
power
)
{
char
suffix
=
'\0'
;
if
(
power
>=
40
)
{
suffix
=
'T'
;
power
-=
40
;
}
else
if
(
power
>=
30
)
{
suffix
=
'G'
;
power
-=
30
;
}
else
if
(
power
>=
20
)
{
suffix
=
'M'
;
power
-=
20
;
}
else
if
(
power
>=
10
)
{
suffix
=
'k'
;
power
-=
10
;
}
std
::
ostringstream
label
;
label
<<
(
1
<<
power
);
if
(
suffix
)
label
<<
suffix
;
return
label
.
str
();
}
}
// namespace bpftrace
src/bpftrace.h
View file @
dcd9e625
...
...
@@ -26,6 +26,7 @@ private:
int
print_map
(
Map
&
map
);
int
print_map_quantize
(
Map
&
map
);
int
print_quantize
(
std
::
vector
<
uint64_t
>
values
);
std
::
string
quantize_index_label
(
int
power
);
};
}
// namespace bpftrace
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