Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
LARN
X-Lap
Commits
123504b6
Commit
123504b6
authored
Apr 17, 2018
by
Andreas Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add multi-correlation plots. Add CDF plots.
parent
5123d833
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
15 deletions
+97
-15
xlap/analyse/cdf.py
xlap/analyse/cdf.py
+36
-0
xlap/analyse/correlation.py
xlap/analyse/correlation.py
+41
-12
xlap/analyse/jitter.py
xlap/analyse/jitter.py
+3
-1
xlap/analyse/util.py
xlap/analyse/util.py
+17
-2
No files found.
xlap/analyse/cdf.py
0 → 100644
View file @
123504b6
import
math
import
numpy
as
np
from
.util
import
cdf
,
extract_durations
import
matplotlib.pyplot
as
plt
def
multi_cdf
(
dfs
,
config
,
export
=
False
,
file_name
=
"CDF.pdf"
):
durations
=
[
x
+
"_D"
for
x
in
extract_durations
(
config
)]
durations
.
remove
(
"EndToEnd_D"
)
cols
=
3
rows
=
int
(
math
.
ceil
(
len
(
durations
)
/
cols
))
items
=
len
(
durations
)
fig
,
axes
=
plt
.
subplots
(
nrows
=
rows
,
ncols
=
cols
)
fig
.
set_size_inches
(
4
*
cols
,
4
*
rows
,
forward
=
True
)
names
=
[]
for
df
in
dfs
:
names
.
append
(
df
.
name
)
for
idx
,
duration
in
enumerate
(
durations
):
if
items
>
cols
:
ax
=
axes
[
idx
//
cols
,
idx
%
cols
]
else
:
ax
=
axes
[
idx
]
for
df
in
dfs
:
cdf
(
df
[
duration
],
grid
=
True
,
ax
=
ax
)
ax
.
legend
(
names
)
ax
.
set_xlabel
(
"{} [us]"
.
format
(
duration
))
ax
.
set_ylabel
(
"CDF"
)
plt
.
subplots_adjust
(
wspace
=
0.3
,
hspace
=
0.3
)
if
export
and
file_name
is
not
None
:
fig
.
savefig
(
file_name
)
plt
.
tight_layout
()
plt
.
show
()
xlap/analyse/correlation.py
View file @
123504b6
...
...
@@ -3,25 +3,54 @@ import matplotlib.pyplot as plt
from
xlap.analyse.util
import
extract_durations
def
correlation
(
data_frame
,
config
,
export
=
False
,
file_name
=
"Correlation.pdf"
):
def
corr
(
df
,
duration
,
grid
=
False
,
ax
=
None
,
color
=
"black"
,
marker
=
"+"
):
df
.
plot
.
scatter
(
ax
=
ax
,
y
=
"EndToEnd_D"
,
x
=
duration
,
grid
=
grid
,
loglog
=
True
,
marker
=
marker
,
color
=
color
)
def
corr_multi
(
dfs
,
duration
,
**
kwargs
):
names
=
[]
for
df
in
dfs
:
names
.
append
(
df
.
name
)
colors
=
[
"green"
,
"blue"
,
"orange"
]
markers
=
[
"v"
,
"^"
,
">"
,
"<"
]
for
idf
,
df
in
enumerate
(
dfs
):
corr
(
df
,
duration
,
color
=
colors
[
idf
%
len
(
colors
)],
marker
=
markers
[
idf
%
len
(
markers
)],
**
kwargs
)
if
len
(
names
)
>
1
:
kwargs
[
"ax"
].
legend
(
names
)
kwargs
[
"ax"
].
set_xlabel
(
"{} [us]"
.
format
(
duration
))
def
multi_correlation
(
dfs
,
config
):
durations
=
[
x
+
"_D"
for
x
in
extract_durations
(
config
)]
durations
.
remove
(
"EndToEnd_D"
)
cols
=
4
cols
=
2
rows
=
int
(
math
.
ceil
(
len
(
durations
)
/
cols
))
items
=
len
(
durations
)
fig
,
axes
=
plt
.
subplots
(
nrows
=
rows
,
ncols
=
cols
)
fig
.
set_size_inches
(
4
*
cols
,
3.5
*
rows
,
forward
=
True
)
fig
.
set_size_inches
(
5.5
*
cols
,
5.5
*
rows
,
forward
=
True
)
for
idx
,
duration
in
enumerate
(
durations
):
if
items
>
cols
:
ax
=
axes
[
idx
//
cols
,
idx
%
cols
]
else
:
ax
=
axes
[
idx
]
corr_multi
(
dfs
,
duration
,
grid
=
True
,
ax
=
ax
)
i
=
0
for
duration
in
durations
:
ax
=
data_frame
.
plot
.
scatter
(
ax
=
axes
[
i
//
cols
,
i
%
cols
],
y
=
"EndToEnd_D"
,
x
=
duration
,
grid
=
True
,
marker
=
"+"
,
color
=
"black"
)
ax
.
set_ylabel
(
"EndToEnd [us]"
)
ax
.
margins
(
0.1
,
0.1
)
ax
.
set_xlabel
(
"{} [us]"
.
format
(
duration
.
replace
(
"_D"
,
""
)))
i
+=
1
plt
.
subplots_adjust
(
wspace
=
0.3
,
hspace
=
0.3
)
def
correlation
(
df
,
config
,
export
=
False
,
file_name
=
"Correlation.pdf"
):
res
=
multi_correlation
([
df
],
config
)
if
export
and
file_name
is
not
None
:
fig
.
savefig
(
file_name
)
plt
.
tight_layout
()
plt
.
show
()
\ No newline at end of file
plt
.
show
()
return
res
xlap/analyse/jitter.py
View file @
123504b6
...
...
@@ -43,4 +43,6 @@ def trace_jitter(data_frame, threshold=None, export=False, file_name=None):
def
prep
(
df
,
config
):
return
df
[[
x
+
"_D"
for
x
in
extract_durations
(
config
)]]
res
=
df
[[
x
+
"_D"
for
x
in
extract_durations
(
config
)]]
res
.
name
=
df
.
name
return
res
xlap/analyse/util.py
View file @
123504b6
import
matplotlib.pyplot
as
plt
from
matplotlib
import
pyplot
as
plt
import
numpy
as
np
import
math
def
cdf
(
values
,
grid
=
False
,
ax
=
None
):
# empirical CDF
def
F
(
x
,
data
):
return
float
(
len
(
data
[
data
<=
x
]))
/
len
(
data
)
vF
=
np
.
vectorize
(
F
,
excluded
=
[
'data'
])
if
ax
is
None
:
ax
=
plt
ax
.
semilogx
(
np
.
sort
(
values
),
vF
(
x
=
np
.
sort
(
values
),
data
=
values
))
if
grid
:
ax
.
grid
()
def
hist
(
df
):
return
df
.
hist
(
cumulative
=
True
,
normed
=
1
,
bins
=
200
)
...
...
@@ -48,4 +63,4 @@ def describe_table(df):
stats
.
columns
=
list
(
map
(
lambda
x
:
x
.
replace
(
"_D"
,
""
),
stats
.
columns
))
table
=
stats
.
to_latex
(
float_format
=
lambda
x
:
"%.3f"
%
x
)
print
(
table
)
return
stats
\ No newline at end of file
return
stats
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