-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcount_time.py
More file actions
49 lines (35 loc) · 1.12 KB
/
count_time.py
File metadata and controls
49 lines (35 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from commands import *
import datetime
def to_min_sec(sec):
min = int(sec // 60)
sec = str(int(sec % 60)).zfill(2)
return min, sec
context = paste()
ll = Str.nl(context)
my = 0
not_my = 0
for cnt, l in enumerate(ll):
if cnt == 0:
continue
if l == "":
continue
previous = ll[cnt-1]
previous = Str.substring(previous, '"', '"')
current = Str.substring(l, '"', '"')
df = "%d.%m.%Y %H:%M:%S"
previous = datetime.datetime.strptime(previous, df)
current = datetime.datetime.strptime(current, df)
delta = Time.delta(previous, current)
#print(ll[cnt-1])
#print(l)
#print(f"{cnt % 2=} {current=} {previous=} {delta=}")
if cnt % 2 == 0:
my += delta
else:
not_my += delta
my_min, my_sec = to_min_sec(my)
not_my_min, not_my_sec = to_min_sec(not_my)
total_min, total_sec = to_min_sec(my + not_my)
result = f"Время выполнения: {my_min}:{my_sec} - обработка у нас, {not_my_min}:{not_my_sec} - обработка запроса на стороне МЛ, {total_min}:{total_sec} всего"
print(result)
copy(result)