mirror of
https://github.com/EDCD/EDDN.git
synced 2025-06-19 00:03:56 +03:00
scripts/apache-log-rate: Attempt to speed up with an array slice
This commit is contained in:
parent
cb1991739e
commit
42129a50ce
@ -45,9 +45,20 @@ def process_log_file(
|
|||||||
# print(f'Timestamp: {this_dt}')
|
# print(f'Timestamp: {this_dt}')
|
||||||
window_dts.append(this_dt)
|
window_dts.append(this_dt)
|
||||||
|
|
||||||
|
# Find the oldest entry that is still within the window:
|
||||||
|
oldest_of_interest = this_dt - window_time_delta
|
||||||
|
dti = 0
|
||||||
|
for dt in window_dts:
|
||||||
|
if dt >= oldest_of_interest:
|
||||||
|
break
|
||||||
|
dti += 1
|
||||||
|
|
||||||
|
window_dts = window_dts[dti:]
|
||||||
|
|
||||||
# Now we need to expire any of the oldest stored timestamps that
|
# Now we need to expire any of the oldest stored timestamps that
|
||||||
# are outside the window relative to this
|
# are outside the window relative to this
|
||||||
window_dts = list(filter(lambda dt: dt >= this_dt - window_time_delta, window_dts))
|
# window_dts = list(filter(lambda dt: dt >= this_dt - window_time_delta, window_dts))
|
||||||
|
|
||||||
if len(window_dts) > window_count:
|
if len(window_dts) > window_count:
|
||||||
window_count = len(window_dts)
|
window_count = len(window_dts)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user