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
75e4b4ca
Commit
75e4b4ca
authored
Jun 01, 2020
by
Joanne Hugé
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add histogram graph generation
parent
3b6cad1a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
3 deletions
+41
-3
measure-analysis/measure-analysis.py
measure-analysis/measure-analysis.py
+41
-3
No files found.
measure-analysis/measure-analysis.py
View file @
75e4b4ca
...
...
@@ -7,9 +7,14 @@ import argparse
import
os
import
parse
import
numpy
as
np
import
matplotlib.mlab
as
mlab
import
matplotlib.pyplot
as
plt
class
MeasureSetHandler
:
measures_dir
=
"measures"
graphs_dir
=
"{}/graphs"
.
format
(
measures_dir
)
measure_sets_file_name
=
"measure_sets.json"
measure_sets_path
=
measures_dir
+
"/"
+
measure_sets_file_name
...
...
@@ -70,6 +75,14 @@ class MeasureSetHandler:
self
.
remove_measure_set
(
mtype
,
mid
)
print
(
"Removed all measures"
.
format
(
mtype
,
mid
))
def
generate_graphs
(
self
):
for
mtype
in
self
.
measure_sets
:
for
mid
in
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
):
with
open
(
self
.
measures_dir
+
"/"
+
"measure_tables.md"
,
'w+'
)
as
measure_table
:
...
...
@@ -202,7 +215,7 @@ class MeasureSet:
def
histogram_to_chronological
(
histogram
):
chrono
=
list
(
map
(
lambda
x
:
[
x
[
1
]]
*
x
[
0
],
list
(
enumerate
(
histogram
))))
chrono
=
list
(
map
(
lambda
x
:
[
x
[
0
]]
*
x
[
1
],
list
(
enumerate
(
histogram
))))
chrono
=
[
x
for
l
in
chrono
for
x
in
l
]
return
chrono
...
...
@@ -292,8 +305,29 @@ class MeasureSet:
self
.
add_chronological
(
props_names
,
props
)
def
generate_graph
(
self
,
path
):
pass
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
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
)
plt
.
savefig
(
"{}{}.png"
.
format
(
path
,
i
))
def
generate_table
(
self
,
headers
=
True
,
values
=
True
,
metadata_mask
=
[],
props_lens
=
[]):
...
...
@@ -348,6 +382,7 @@ def parse_args():
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
(
'-G'
,
action
=
'store_true'
,
required
=
False
,
help
=
'generate all graphs'
)
parser
.
add_argument
(
'-s'
,
action
=
'store_true'
,
help
=
'show measures'
)
args
=
parser
.
parse_args
()
...
...
@@ -374,6 +409,9 @@ def parse_args():
if
args
.
T
:
ms_handler
.
generate_tables
()
if
args
.
G
:
ms_handler
.
generate_graphs
()
if
args
.
remove_all
:
confirm
=
input
(
"Are you sure all measure sets should be removed ? [Yes] / [No]: "
)
if
confirm
==
"Yes"
:
...
...
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