Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LARN
X-Lap
Commits
c26ea990
Commit
c26ea990
authored
May 15, 2017
by
Andreas Schmidt
Browse files
Add a sample notebook. Refactor regression out.
parent
034268b7
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
notebook.ipynb
View file @
c26ea990
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
xlap.yml
View file @
c26ea990
...
@@ -112,10 +112,6 @@ durations:
...
@@ -112,10 +112,6 @@ durations:
Start
:
PrrtSendEnd
Start
:
PrrtSendEnd
Stop
:
LinkTransmitStart
Stop
:
LinkTransmitStart
Source
:
sender
Source
:
sender
Encoding
:
Start
:
PrrtEncodeStart
Stop
:
PrrtEncodeEnd
Source
:
sender
ReceiverIPC
:
ReceiverIPC
:
Start
:
PrrtReturnPackage
Start
:
PrrtReturnPackage
...
...
xlap/analyse/__init__.py
View file @
c26ea990
import
math
import
math
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
plt
.
rcParams
[
"figure.figsize"
]
=
(
16
,
9
)
plt
.
rcParams
[
"figure.figsize"
]
=
(
16
,
9
)
...
@@ -10,54 +10,21 @@ plt.rcParams.update({'figure.autolayout': True})
...
@@ -10,54 +10,21 @@ plt.rcParams.update({'figure.autolayout': True})
def
trace
(
df
,
title
,
export
=
False
):
def
box
(
data_frame
,
export
=
False
,
file_name
=
None
):
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
4.5
))
"""
plt
.
grid
()
Display a boxplot for the durations contained in data_frame.
:param data_frame:
base
=
df
[
"PrrtSendStart_T"
]
:param export:
:param file_name:
sender_color
=
"#AAAAAA"
:return:
receiver_color
=
"#888888"
"""
ax
=
data_frame
.
plot
.
box
(
vert
=
False
,
grid
=
True
)
series
=
np
.
transpose
(
np
.
array
([
[
"PrrtSendStart_T"
,
"PrrtDeliver_T"
,
"black"
,
"EndToEnd"
],
[
"PrrtSendStart_T"
,
"LinkTransmitEnd_T"
,
sender_color
,
"SenderTotal"
],
[
"PrrtSendStart_T"
,
"PrrtSendEnd_T"
,
sender_color
,
"Send"
],
[
"PrrtSendStart_T"
,
"PrrtSubmitPackage_T"
,
sender_color
,
"Submit"
],
[
"PrrtSubmitPackage_T"
,
"PrrtTransmitStart_T"
,
sender_color
,
"SenderIPC"
],
[
"PrrtSubmitPackage_T"
,
"PrrtSendEnd_T"
,
sender_color
,
"Enqueue"
],
[
"PrrtSendEnd_T"
,
"LinkTransmitStart_T"
,
sender_color
,
"SenderEnqueued"
],
[
"PrrtTransmitStart_T"
,
"PrrtTransmitEnd_T"
,
sender_color
,
"PrrtTransmit"
],
[
"LinkTransmitStart_T"
,
"LinkTransmitEnd_T"
,
sender_color
,
"LinkTransmit"
],
[
"LinkReceive_T"
,
"PrrtDeliver_T"
,
receiver_color
,
"ReceiverTotal"
],
# ["DecodeStart_T", "DecodeEnd_T", receiver_color, "Decoding"],
[
"HandlePacketStart_T"
,
"HandlePacketEnd_T"
,
receiver_color
,
"HandlePacket"
],
[
"PrrtReturnPackage_T"
,
"PrrtReceivePackage_T"
,
receiver_color
,
"ReceiverIPC"
],
[
"SendFeedbackStart_T"
,
"SendFeedbackEnd_T"
,
receiver_color
,
"Feedback"
],
]))
n
=
series
.
shape
[
1
]
starts
=
df
[
series
[
0
]]
-
base
ends
=
df
[
series
[
1
]]
-
base
plt
.
hlines
(
range
(
n
),
starts
,
ends
,
series
[
2
],
linewidths
=
[
5
])
plt
.
xlabel
(
"Time [us]"
)
fig
.
canvas
.
draw
()
ax
.
set_yticklabels
(
series
[
3
])
ax
.
yaxis
.
set_ticks
(
np
.
arange
(
0
,
n
,
1
))
if
export
:
plt
.
savefig
(
title
)
plt
.
show
()
def
box
(
df_data
,
export
=
False
,
title
=
None
):
ax
=
df_data
.
plot
.
box
(
vert
=
False
,
grid
=
True
)
fig
=
ax
.
get_figure
()
fig
=
ax
.
get_figure
()
ax
.
set_yticklabels
(
list
(
map
(
lambda
x
:
x
.
get_text
().
replace
(
"_D"
,
""
),
ax
.
get_yticklabels
())))
ax
.
set_yticklabels
(
list
(
map
(
lambda
x
:
x
.
get_text
().
replace
(
"_D"
,
""
),
ax
.
get_yticklabels
())))
plt
.
xlabel
(
"Time [us]"
)
plt
.
xlabel
(
"Time [us]"
)
fig
.
set_size_inches
(
8
,
4.5
,
forward
=
True
)
fig
.
set_size_inches
(
8
,
4.5
,
forward
=
True
)
if
export
and
titl
e
is
not
None
:
if
export
and
file_nam
e
is
not
None
:
fig
.
savefig
(
titl
e
)
fig
.
savefig
(
file_nam
e
)
def
describe_table
(
df
):
def
describe_table
(
df
):
...
@@ -87,7 +54,7 @@ def correlation(df_data, title="Correlation.pdf"):
...
@@ -87,7 +54,7 @@ def correlation(df_data, title="Correlation.pdf"):
i
=
0
i
=
0
for
column
in
columns
:
for
column
in
columns
:
ax
=
df_data
.
plot
.
scatter
(
ax
=
axes
[
i
//
cols
,
i
%
cols
],
y
=
"EndToEnd
Time
"
,
x
=
column
,
grid
=
True
,
marker
=
"+"
,
ax
=
df_data
.
plot
.
scatter
(
ax
=
axes
[
i
//
cols
,
i
%
cols
],
y
=
"EndToEnd
_D
"
,
x
=
column
,
grid
=
True
,
marker
=
"+"
,
color
=
"black"
)
color
=
"black"
)
ax
.
set_ylabel
(
"EndToEnd [us]"
)
ax
.
set_ylabel
(
"EndToEnd [us]"
)
ax
.
margins
(
0.1
,
0.1
)
ax
.
margins
(
0.1
,
0.1
)
...
...
xlap/analyse/common.py
View file @
c26ea990
...
@@ -18,7 +18,7 @@ def _filter(x, durations, source):
...
@@ -18,7 +18,7 @@ def _filter(x, durations, source):
def
extract_durations
(
config
):
def
extract_durations
(
config
):
durations
=
config
[
"durations"
]
durations
=
config
[
"durations"
]
durations_send
=
[
_dn
(
x
)
for
x
in
durations
if
_filter
(
x
,
durations
,
"sender"
)]
durations_send
=
[
x
for
x
in
durations
if
_filter
(
x
,
durations
,
"sender"
)]
durations_recv
=
[
_dn
(
x
)
for
x
in
durations
if
_filter
(
x
,
durations
,
"receiver"
)]
durations_recv
=
[
x
for
x
in
durations
if
_filter
(
x
,
durations
,
"receiver"
)]
return
[
"EndToEnd
Time
"
,
"Sender
_D
"
]
+
durations_send
+
[
"Receiver
_D
"
]
+
durations_recv
return
[
"EndToEnd"
,
"Sender"
]
+
durations_send
+
[
"Receiver"
]
+
durations_recv
xlap/analyse/jitter.py
View file @
c26ea990
...
@@ -5,9 +5,9 @@ from xlap.analyse import box
...
@@ -5,9 +5,9 @@ from xlap.analyse import box
def
jitter_causes
(
df
,
durations
,
export
=
False
,
file_name
=
None
):
def
jitter_causes
(
df
,
durations
,
export
=
False
,
file_name
=
None
):
stats
=
df
[
"EndToEnd
Time
"
].
describe
()
stats
=
df
[
"EndToEnd
_D
"
].
describe
()
threshold
=
get_outlier_threshold
(
stats
)
threshold
=
get_outlier_threshold
(
stats
)
outliers
=
df
[
df
[
"EndToEnd
Time
"
]
>
threshold
]
outliers
=
df
[
df
[
"EndToEnd
_D
"
]
>
threshold
]
reasons
=
[
d
+
"_D"
for
d
in
durations
.
keys
()]
reasons
=
[
d
+
"_D"
for
d
in
durations
.
keys
()]
...
@@ -33,8 +33,8 @@ def trace_jitter(data_frame, export=False, file_name=None):
...
@@ -33,8 +33,8 @@ def trace_jitter(data_frame, export=False, file_name=None):
"""
"""
Displays (and saves) a stacked boxplot of durations.
Displays (and saves) a stacked boxplot of durations.
"""
"""
thresh
=
get_outlier_threshold
(
data_frame
[
"EndToEnd
Time
"
].
describe
())
thresh
=
get_outlier_threshold
(
data_frame
[
"EndToEnd
_D
"
].
describe
())
df_no_outliers
=
data_frame
[
data_frame
[
"EndToEnd
Time
"
]
<=
thresh
]
df_no_outliers
=
data_frame
[
data_frame
[
"EndToEnd
_D
"
]
<=
thresh
]
box
(
df_no_outliers
,
export
,
file_name
)
box
(
df_no_outliers
,
export
,
file_name
)
print
(
"{} / {} are no outliers."
.
format
(
len
(
df_no_outliers
),
len
(
data_frame
)))
print
(
"{} / {} are no outliers."
.
format
(
len
(
df_no_outliers
),
len
(
data_frame
)))
fig
=
plt
.
gcf
()
fig
=
plt
.
gcf
()
...
@@ -45,4 +45,4 @@ def trace_jitter(data_frame, export=False, file_name=None):
...
@@ -45,4 +45,4 @@ def trace_jitter(data_frame, export=False, file_name=None):
def
prep
(
df
,
config
):
def
prep
(
df
,
config
):
plt
.
rcParams
[
"figure.figsize"
]
=
(
16
,
9
)
plt
.
rcParams
[
"figure.figsize"
]
=
(
16
,
9
)
plt
.
rcParams
.
update
({
'figure.autolayout'
:
True
})
plt
.
rcParams
.
update
({
'figure.autolayout'
:
True
})
return
df
[
extract_durations
(
config
)]
return
df
[
[
x
+
"_D"
for
x
in
extract_durations
(
config
)]
]
xlap/analyse/trace.py
0 → 100644
View file @
c26ea990
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
xlap.analyse.common
import
extract_durations
def
_create_line
(
config
):
tr
=
config
[
"time_reference"
]
color
=
{
"sender"
:
"#AAAAAA"
,
"receiver"
:
"#888888"
,
"e2e"
:
"black"
}
def
_creator
(
duration_name
):
if
duration_name
==
"EndToEnd"
:
return
[
tr
[
"sender"
][
"Start"
]
+
"_T"
,
tr
[
"receiver"
][
"Stop"
]
+
"_T"
,
color
[
"e2e"
],
"EndToEnd"
]
elif
duration_name
==
"Sender"
:
return
[
tr
[
"sender"
][
"Start"
]
+
"_T"
,
tr
[
"sender"
][
"Stop"
]
+
"_T"
,
color
[
"sender"
],
"Sender"
]
elif
duration_name
==
"Receiver"
:
return
[
tr
[
"receiver"
][
"Start"
]
+
"_T"
,
tr
[
"receiver"
][
"Stop"
]
+
"_T"
,
color
[
"receiver"
],
"Receiver"
]
else
:
duration
=
config
[
"durations"
][
duration_name
]
return
[
duration
[
"Start"
]
+
"_T"
,
duration
[
"Stop"
]
+
"_T"
,
color
[
duration
[
"Source"
]],
duration_name
]
return
_creator
def
trace
(
data_frame
,
config
,
export
=
False
,
file_name
=
"TraceJitter.pdf"
):
"""
:param data_frame:
:param config:
:param export:
:param file_name:
:return:
"""
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
4.5
))
plt
.
grid
()
line_creator
=
_create_line
(
config
)
durations
=
[
line_creator
(
x
)
for
x
in
extract_durations
(
config
)]
series
=
np
.
transpose
(
np
.
array
(
durations
))
n
=
series
.
shape
[
1
]
# Starts and Ends
tr
=
config
[
"time_reference"
]
base
=
data_frame
[
tr
[
"sender"
][
"Start"
]
+
"_T"
]
starts
=
data_frame
[
series
[
0
]]
-
base
ends
=
data_frame
[
series
[
1
]]
-
base
plt
.
hlines
(
range
(
n
),
starts
,
ends
,
series
[
2
],
linewidths
=
[
5
])
plt
.
xlabel
(
"Time [us]"
)
fig
.
canvas
.
draw
()
ax
.
set_yticklabels
(
series
[
3
])
ax
.
yaxis
.
set_ticks
(
np
.
arange
(
0
,
n
,
1
))
if
export
:
plt
.
savefig
(
file_name
)
plt
.
show
()
xlap/parse.py
View file @
c26ea990
...
@@ -76,7 +76,7 @@ def evaluate(sender_file, receiver_file, config, kind=0):
...
@@ -76,7 +76,7 @@ def evaluate(sender_file, receiver_file, config, kind=0):
df
[
name
+
"Cycles"
]
=
diff
df
[
name
+
"Cycles"
]
=
diff
df
[
name
+
"_D"
]
=
diff
*
df
[
duration
[
"Source"
].
capitalize
()
+
"Cycle_D"
]
df
[
name
+
"_D"
]
=
diff
*
df
[
duration
[
"Source"
].
capitalize
()
+
"Cycle_D"
]
df
[
"EndToEnd
Time
"
]
=
df
[
"Sender_D"
]
+
df
[
"Receiver_D"
]
df
[
"EndToEnd
_D
"
]
=
df
[
"Sender_D"
]
+
df
[
"Receiver_D"
]
return
df
return
df
...
...
Write
Preview
Supports
Markdown
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