-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime_statistics.py
39 lines (33 loc) · 1.01 KB
/
time_statistics.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/10/29 14:29
# @Author : laazy
# @Site :
# @File : time_statistics.py
# @Software: PyCharm
import log_deal2
class TimeStatistic:
def __init__(self):
pass
def get_time(self, log):
ans = {}
for job in log:
ans[job] = self.get_time_by_job(log, job)
return ans
@staticmethod
def get_time_by_job(log, job):
ans = {"map": 0, "shuffle": 0, "reduce": 0}
for node in log[job]:
for task in log[job][node]:
for status in ans:
if log[job][node][task].get(status) is None:
continue
time = log[job][node][task][status]
ans[status] += (time[1] - time[0])
return ans
if __name__ == '__main__':
logs = log_deal2.LogDealer()
statistic = TimeStatistic()
logs.load_dirs()
t = statistic.get_time(logs.get_output())
print(t)