Skip to content

Instantly share code, notes, and snippets.

@maxbeutel
Created May 25, 2021 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxbeutel/1dbda2e16fa5a08a937755d15833202d to your computer and use it in GitHub Desktop.
Save maxbeutel/1dbda2e16fa5a08a937755d15833202d to your computer and use it in GitHub Desktop.
series = [
10,
57,
33,
21,
19,
20,
18,
17,
24,
89,
21,
22,
22,
22,
23,
27,
29,
30,
30,
31,
30,
29,
30,
31,
32,
18, #####
33,
21,
19,
20,
18,
17,
24,
21,
19,
20,
18,
17,
24,
50,
55,
56,
52,
57,
49,
18,
17,
24,
21,
19,
19,
]
T1 = 25 # Detect threshold
T2 = 0.75 * T1 # Undetect threshold
M = 6 # At least M minutes we need to have exceeded
##############
processed = []
counter = 0
for t, response_time in enumerate(series):
if response_time > T1 or response_time > T2:
counter += 1
else:
counter = 0
processed.append((t, response_time, counter))
highlight = -1
for (t, response_time, counter) in reversed(processed):
marker = ''
if counter > M and highlight == -1:
highlight = counter
if highlight > 0:
highlight -= 1
marker = '<<<<<<<<<<<'
if highlight == 0:
highlight = -1
print(t, '\t', response_time, '\t', counter, '\t', marker)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment