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
f13dc492
Commit
f13dc492
authored
Jun 01, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add header, value and metadata option to generate_table
parent
68ae81be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
20 deletions
+44
-20
measure-analysis/measure-analysis.py
measure-analysis/measure-analysis.py
+44
-20
No files found.
measure-analysis/measure-analysis.py
View file @
f13dc492
...
...
@@ -68,9 +68,10 @@ class MeasureSet:
def
__init__
(
self
):
self
.
board
=
"Emerald"
self
.
linux_version
=
"4.19"
self
.
boot_params
=
"isolcpus"
self
.
metadata
=
{}
self
.
metadata
[
'board'
]
=
"Emerald"
self
.
metadata
[
'linux_version'
]
=
"4.19"
self
.
metadata
[
'boot_params'
]
=
"isolcpus"
self
.
cols
=
{}
self
.
interval
=
0
...
...
@@ -86,13 +87,14 @@ class MeasureSet:
self
.
linux_version
=
linux_version
self
.
boot_params
=
boot_params
def
add_results
(
self
,
measure_type
,
interval
,
col_names
,
units
,
cols
):
def
add_results
(
self
,
measure_type
,
interval
,
col_names
,
units
,
cols
,
metadata
):
self
.
measure_type
=
measure_type
self
.
cols
=
cols
self
.
col_names
=
col_names
self
.
interval
=
interval
self
.
units
=
units
self
.
metadata
.
update
(
metadata
)
self
.
max
=
[
max
(
col
)
for
col
in
cols
]
self
.
min
=
[
min
(
col
)
for
col
in
cols
]
...
...
@@ -102,7 +104,7 @@ class MeasureSet:
def
export_to_json
(
self
,
path
):
with
open
(
path
,
'w'
)
as
outfile
:
json
.
dump
({
'measure_type'
:
self
.
measure_type
,
'interval'
:
self
.
interval
,
'col_names'
:
self
.
col_names
,
'units'
:
self
.
units
,
'cols'
:
self
.
cols
},
outfile
)
json
.
dump
({
'measure_type'
:
self
.
measure_type
,
'interval'
:
self
.
interval
,
'col_names'
:
self
.
col_names
,
'units'
:
self
.
units
,
'cols'
:
self
.
cols
,
'metadata'
:
self
.
metadata
},
outfile
)
def
import_from_json
(
self
,
path
,
flat
):
...
...
@@ -113,6 +115,7 @@ class MeasureSet:
interval
=
data
[
'interval'
]
col_names
=
data
[
'col_names'
]
units
=
data
[
'units'
]
metadata
=
data
[
'metadata'
]
if
flat
:
...
...
@@ -127,31 +130,52 @@ class MeasureSet:
else
:
cols
=
data
[
'cols'
]
self
.
add_results
(
measure_type
,
interval
,
col_names
,
units
,
cols
)
self
.
add_results
(
measure_type
,
interval
,
col_names
,
units
,
cols
,
metadata
)
def
generate_graph
(
self
,
path
):
pass
def
generate_table
(
self
):
def
generate_table
(
self
,
headers
=
True
,
values
=
True
,
metadata_mask
=
{}
):
m
=
[
self
.
min
,
self
.
max
,
self
.
avg
,
self
.
var
]
if
headers
==
False
and
values
==
False
:
return
""
headers
=
[
"Min"
,
"Max"
,
"Avg"
,
"Var"
]
values
=
[[
(
format
(
m
[
i
][
j
],
'.4f'
)
+
self
.
units
[
j
])
for
j
in
range
(
len
(
m
[
0
]))]
for
i
in
range
(
len
(
m
))]
table
=
[]
table
=
[
headers
]
table
+=
[[
"**"
+
" - "
.
join
(
self
.
col_names
)
+
"**"
]
*
len
(
headers
)]
table
+=
[[
" - "
.
join
(
values
[
i
])
for
i
in
range
(
len
(
values
))]]
if
headers
:
headers
=
[
"Min"
,
"Max"
,
"Avg"
,
"Var"
]
if
metadata_mask
!=
{}:
table
+=
[[
"Metadata"
]
+
headers
]
table
+=
[[
"**"
+
", "
.
join
(
metadata_mask
)
+
"**"
]
+
[
"**"
+
" - "
.
join
(
self
.
col_names
)
+
"**"
]
*
len
(
headers
)]
else
:
table
+=
[
headers
]
table
+=
[[
"**"
+
" - "
.
join
(
self
.
col_names
)
+
"**"
]
*
len
(
headers
)]
if
values
:
m
=
[
self
.
min
,
self
.
max
,
self
.
avg
,
self
.
var
]
values
=
[[
(
format
(
m
[
i
][
j
],
'.4f'
)
+
self
.
units
[
j
])
for
j
in
range
(
len
(
m
[
0
]))]
for
i
in
range
(
len
(
m
))]
if
metadata_mask
!=
{}:
metadata_info
=
[
"{}"
.
format
(
self
.
metadata
[
metadata_name
])
for
metadata_name
in
metadata_mask
]
table
+=
[[
", "
.
join
(
metadata_info
)]
+
[
" - "
.
join
(
values
[
i
])
for
i
in
range
(
len
(
values
))]]
else
:
table
+=
[[
" - "
.
join
(
values
[
i
])
for
i
in
range
(
len
(
values
))]]
col_lens
=
[
max
([
len
(
table
[
i
][
j
])
for
i
in
range
(
len
(
table
))])
for
j
in
range
(
len
(
table
[
0
]))]
table
=
[[
table
[
i
][
j
].
ljust
(
col_lens
[
j
])
for
j
in
range
(
len
(
table
[
0
]))]
for
i
in
range
(
len
(
table
))]
table_str
=
" | "
.
join
(
table
[
0
])
+
"
\
n
"
table_str
+=
" | "
.
join
([
(
"-"
*
col_lens
[
i
])
for
i
in
range
(
len
(
col_lens
))
])
+
"
\
n
"
table_str
+=
"
\
n
"
.
join
([
" | "
.
join
(
line
)
for
line
in
table
[
1
:]])
table_str
=
""
if
headers
:
table_str
+=
" | "
.
join
(
table
[
0
])
+
"
\
n
"
table_str
+=
" | "
.
join
([
(
"-"
*
col_lens
[
i
])
for
i
in
range
(
len
(
col_lens
))
])
+
"
\
n
"
if
values
:
table_str
+=
"
\
n
"
.
join
([
" | "
.
join
(
line
)
for
line
in
table
[
1
:]])
else
:
table_str
+=
"
\
n
"
.
join
([
" | "
.
join
(
line
)
for
line
in
table
])
return
table_str
...
...
@@ -177,7 +201,7 @@ def parse():
elif
args
.
t
is
not
None
and
args
.
t
!=
"input_file"
:
measure_set
=
ms_handler
.
get_measure_set
(
args
.
t
)
print
(
measure_set
.
generate_table
())
print
(
measure_set
.
generate_table
(
True
,
True
,
{
'board'
,
'linux_version'
,
'boot_params'
}
))
if
args
.
remove_all
:
confirm
=
input
(
"Are you sure all measure sets should be removed ? [Yes] / [No]: "
)
...
...
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