Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
tsn-measures
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
tsn-measures
Commits
6a1b2c3f
Commit
6a1b2c3f
authored
Jun 01, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add full report generation
parent
75e4b4ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
42 deletions
+64
-42
measure-analysis/measure-analysis.py
measure-analysis/measure-analysis.py
+64
-42
No files found.
measure-analysis/measure-analysis.py
View file @
6a1b2c3f
...
...
@@ -77,28 +77,54 @@ class MeasureSetHandler:
def
generate_graphs
(
self
):
for
mtype
in
self
.
measure_sets
:
for
mid
in
self
.
measure_sets
[
mtype
][
'ids'
]:
colors
=
[
'red'
,
'blue'
,
'green'
]
for
mtype
in
self
.
measure_sets
:
measures
=
[]
for
mid
in
self
.
measure_sets
[
mtype
][
'ids'
]:
measures
.
append
(
self
.
get_measure_set
(
"{}{}"
.
format
(
mtype
,
mid
)))
if
len
(
measures
)
==
0
:
continue
nb_props
=
len
(
measures
[
0
].
props
)
for
i
in
range
(
nb_props
):
for
j
,
mid
in
enumerate
(
self
.
measure_sets
[
mtype
][
'ids'
]):
measure
=
self
.
get_measure_set
(
"{}{}"
.
format
(
mtype
,
mid
))
graph_name
=
"{}{}"
.
format
(
mtype
,
mid
)
measure
.
generate_graph
(
graph_name
,
"{}/{}"
.
format
(
MeasureSetHandler
.
graphs_dir
,
graph_name
))
def
generate_tables
(
self
):
measure
.
generate_histogram
(
i
,
colors
[
j
])
fig
,
ax
=
plt
.
gcf
(),
plt
.
gca
()
ax
.
set_xlabel
(
'Latency (us)'
)
ax
.
set_ylabel
(
'Number of latency samples'
)
ax
.
set_title
(
'{}, {} histogram'
.
format
(
mtype
,
measures
[
0
].
props_names
[
i
]))
fig
.
set_size_inches
(
11.0
,
5.5
)
plt
.
savefig
(
"{}/{}{}.png"
.
format
(
MeasureSetHandler
.
graphs_dir
,
mtype
,
measures
[
0
].
props_names
[
i
]))
def
generate_report
(
self
,
include_graphs
=
True
):
if
include_graphs
:
self
.
generate_graphs
()
with
open
(
self
.
measures_dir
+
"/"
+
"measure
_tables.md"
,
'w+'
)
as
measure_table
:
with
open
(
self
.
measures_dir
+
"/"
+
"measure
-report.md"
,
'w+'
)
as
report
:
measure_table
.
write
(
"## Measurements table
s
\
n
\
n
"
)
report
.
write
(
"## Measurement
s
\
n
\
n
"
)
measure_table
.
write
(
"### Abbreviations used
\
n
\
n
"
)
report
.
write
(
"### Abbreviations used
\
n
\
n
"
)
for
abbr_name
in
MeasureSet
.
abbreviations
:
measure_table
.
write
(
"* {}: {}
\
n
"
.
format
(
abbr_name
,
MeasureSet
.
abbreviations
[
abbr_name
]))
measure_table
.
write
(
"
\
n
"
)
report
.
write
(
"* {}: {}
\
n
"
.
format
(
abbr_name
,
MeasureSet
.
abbreviations
[
abbr_name
]))
report
.
write
(
"
\
n
"
)
for
mtype
in
self
.
measure_sets
:
need_header
=
True
props_lens
=
[]
measure_table
.
write
(
"### {} tables
\
n
\
n
"
.
format
(
mtype
))
report
.
write
(
"### {} tables
\
n
\
n
"
.
format
(
mtype
))
# Generate the metadata mask, by grouping the identical metadatas
metadata_mask
=
[]
...
...
@@ -120,12 +146,12 @@ class MeasureSetHandler:
# Write the identical metadatas before the table
measure_table
.
write
(
"**Common metadatas:** "
)
report
.
write
(
"**Common metadatas:** "
)
common_metadatas
=
[]
for
metadata_name
in
first_metadata
:
if
metadata_name
not
in
metadata_mask
:
common_metadatas
.
append
(
"{}: {}"
.
format
(
MeasureSet
.
abbreviations
[
metadata_name
],
first_metadata
[
metadata_name
]))
measure_table
.
write
(
", "
.
join
(
common_metadatas
)
+
"
\
n
\
n
"
)
report
.
write
(
", "
.
join
(
common_metadatas
)
+
"
\
n
\
n
"
)
for
mid
in
self
.
measure_sets
[
mtype
][
'ids'
]:
...
...
@@ -134,14 +160,22 @@ class MeasureSetHandler:
if
need_header
:
table_str
,
props_lens
=
measure
.
generate_table
(
headers
=
True
,
metadata_mask
=
metadata_mask
)
measure_table
.
write
(
table_str
)
report
.
write
(
table_str
)
need_header
=
False
else
:
measure_table
.
write
(
measure
.
generate_table
(
headers
=
False
,
props_lens
=
props_lens
,
metadata_mask
=
metadata_mask
)[
0
])
report
.
write
(
measure
.
generate_table
(
headers
=
False
,
props_lens
=
props_lens
,
metadata_mask
=
metadata_mask
)[
0
])
measure_table
.
write
(
"
\
n
"
)
measure_table
.
write
(
"
\
n
"
)
measure_table
.
write
(
"
\
n
"
)
report
.
write
(
"
\
n
"
)
# Include the graphs
if
include_graphs
:
for
i
in
range
(
len
(
measures
[
0
].
props
)):
report
.
write
(
'
\
n
![alt text](graphs/{}{}.png "{} Graph")
\
n
'
.
format
(
mtype
,
measures
[
0
].
props_names
[
i
],
mtype
,
measures
[
0
].
props_names
[
i
]))
report
.
write
(
"
\
n
"
)
report
.
write
(
"
\
n
"
)
class
MeasureSet
:
...
...
@@ -170,7 +204,7 @@ class MeasureSet:
def
__str__
(
self
):
return
"Cols: "
+
str
(
self
.
props
)
+
"
\
n
Interval: "
+
str
(
self
.
interval
)
return
"Cols: "
+
str
(
self
.
props
)
+
"
\
n
"
def
input_metadata
(
self
):
...
...
@@ -305,29 +339,17 @@ class MeasureSet:
self
.
add_chronological
(
props_names
,
props
)
def
generate_graph
(
self
,
name
,
path
):
if
self
.
props_type
==
'histogram'
:
for
i
in
range
(
len
(
self
.
props
)):
histogram
=
MeasureSet
.
histogram_to_chronological
(
self
.
props
[
i
])
n
,
bins
,
patches
=
plt
.
hist
(
histogram
,
len
(
self
.
props
[
i
]),
facecolor
=
'red'
,
alpha
=
0.5
)
max_height
=
max
([
patch
.
get_height
()
for
patch
in
patches
])
min_height
=
max_height
/
100.0
def
generate_histogram
(
self
,
i
,
color
):
histogram
=
MeasureSet
.
histogram_to_chronological
(
self
.
props
[
i
])
n
,
bins
,
patches
=
plt
.
hist
(
histogram
,
len
(
self
.
props
[
i
]),
facecolor
=
color
,
alpha
=
0.5
)
for
j
,
patch
in
enumerate
(
patches
):
height
=
patch
.
get_height
()
if
self
.
props
[
i
][
j
]
>
0
and
height
<
min_height
:
patch
.
set_height
(
min_height
)
fig
,
ax
=
plt
.
gcf
(),
plt
.
gca
()
ax
.
set_xlabel
(
'Latency (us)'
)
ax
.
set_ylabel
(
'Number of latency samples'
)
ax
.
set_title
(
'{}, {} histogram'
.
format
(
name
,
self
.
props_names
[
i
]))
fig
.
set_size_inches
(
11.0
,
5.5
)
max_height
=
max
([
patch
.
get_height
()
for
patch
in
patches
])
min_height
=
max_height
/
100.0
plt
.
savefig
(
"{}{}.png"
.
format
(
path
,
i
))
for
j
,
patch
in
enumerate
(
patches
):
height
=
patch
.
get_height
()
if
self
.
props
[
i
][
j
]
>
0
and
height
<
min_height
:
patch
.
set_height
(
min_height
)
def
generate_table
(
self
,
headers
=
True
,
values
=
True
,
metadata_mask
=
[],
props_lens
=
[]):
...
...
@@ -381,7 +403,7 @@ def parse_args():
parser
.
add_argument
(
'-c'
,
action
=
'store_true'
,
required
=
False
,
help
=
'parse cyclictest histogram'
)
parser
.
add_argument
(
'--remove-all'
,
action
=
'store_true'
,
help
=
'remove all measure sets'
)
parser
.
add_argument
(
'-t'
,
nargs
=
'?'
,
const
=
'input_file'
,
required
=
False
,
help
=
'generate table'
)
parser
.
add_argument
(
'-
T'
,
action
=
'store_true'
,
required
=
False
,
help
=
'generate all tables
'
)
parser
.
add_argument
(
'-
R'
,
action
=
'store_true'
,
required
=
False
,
help
=
'generate full measure report
'
)
parser
.
add_argument
(
'-G'
,
action
=
'store_true'
,
required
=
False
,
help
=
'generate all graphs'
)
parser
.
add_argument
(
'-s'
,
action
=
'store_true'
,
help
=
'show measures'
)
...
...
@@ -406,8 +428,8 @@ def parse_args():
measure_set
=
ms_handler
.
get_measure_set
(
args
.
t
)
print
(
measure_set
.
generate_table
(
True
,
True
,
{
'board'
,
'linux_version'
,
'boot_params'
})[
0
])
if
args
.
T
:
ms_handler
.
generate_
tables
()
if
args
.
R
:
ms_handler
.
generate_
report
()
if
args
.
G
:
ms_handler
.
generate_graphs
()
...
...
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