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
f47333ab
Commit
f47333ab
authored
Feb 13, 2018
by
Andreas Schmidt
Browse files
Speed-up happens before by using pandas logical operations.
parent
b6c6d92d
Changes
1
Hide whitespace changes
Inline
Side-by-side
xlap/analyse/latency.py
View file @
f47333ab
...
...
@@ -17,7 +17,6 @@ def _happens_before(df, a, b, config):
"""
check if a happens-before b in the trace
"""
l
=
len
(
df
[
a
])
# check whether a and b occur in the same thread. If so, a and b cannot be
# concurrent.
ta
=
_get_thread_for_event
(
config
,
a
)
...
...
@@ -25,23 +24,15 @@ def _happens_before(df, a, b, config):
cname_a
=
str
(
a
)[:
-
2
]
+
"_C"
cname_b
=
str
(
b
)[:
-
2
]
+
"_C"
if
(
ta
==
tb
and
ta
!=
None
and
tb
!=
None
):
for
i
in
range
(
l
):
tsa
=
df
[
a
].
iloc
[
i
]
tsb
=
df
[
b
].
iloc
[
i
]
if
tsa
>
tsb
:
return
False
csa
=
df
[
cname_a
].
iloc
[
i
]
csb
=
df
[
cname_b
].
iloc
[
i
]
if
tsa
==
tsb
and
csa
>
csb
and
csb
!=
0
:
return
False
return
True
tg
=
df
[
a
]
>
df
[
b
]
if
tg
.
any
():
return
False
df2
=
df
[
df
[
a
]
==
df
[
b
]]
return
not
((
df2
[
cname_a
]
>
df2
[
cname_b
])
&
df2
[
cname_b
]
!=
0
).
any
()
# since a and b occur in different threads, we cannot compare cyclestamps.
# If in doubt, a and b are concurrent.
for
i
in
range
(
l
):
if
df
[
a
].
iloc
[
i
]
>=
df
[
b
].
iloc
[
i
]:
return
False
return
True
return
not
(
df
[
a
]
>=
df
[
b
]).
any
()
def
_fast_happens_before
(
df
,
a
,
b
,
hb
):
"""
...
...
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