コード例 #1
0
def main():
    pickle_filenames = [
        '2021-01-01-09-01-49-云到边-ep.pk',
        '2021-01-01-09-03-45-云到边-lrp.pk',
        '2021-01-01-09-05-21-云到边-mrp.pk',
        '2021-01-01-09-06-56-云到边-bra.pk',
    ]
    pickle_dir = 'results/pods'
    pickle_filenames = [
        os.path.join(pickle_dir, pf) for pf in pickle_filenames
    ]

    benchmark = datetime.datetime(2000,
                                  1,
                                  1,
                                  0,
                                  0,
                                  0,
                                  0,
                                  tzinfo=pytz.timezone('UTC'))

    pods = []
    for pf in pickle_filenames:
        pod_list = read_pod_from_file(pf)
        first_start_time = min(
            [utils.get_pod_creation_timestamp(p) for p in pod_list])
        for p in pod_list:
            p.metadata.name = p.metadata.name + '-' + pf.split('-')[-1].split(
                '.')[0]
            p.metadata.creation_timestamp = utils.get_pod_creation_timestamp(
                p) - first_start_time + benchmark
            p.status.container_statuses[
                0].state.terminated.started_at = utils.get_pod_start_time(
                    p) - first_start_time + benchmark
            p.status.container_statuses[
                0].state.terminated.finished_at = utils.get_pod_finish_time(
                    p) - first_start_time + benchmark
        pods.extend(pod_list)

    pods.sort(key=utils.get_obj_name)

    draw_task_gantt(pods)
    draw_task_wait_gantt(pods)
    draw_task_run_gantt(pods)
コード例 #2
0
ファイル: gantt.py プロジェクト: wenshilin/k8s-benchmark
def create_gantt_data(pods: List[V1Pod], data_type: str):
    pod_dicts = []
    jobs = {}
    for pod in pods:
        job_name = utils.get_pod_job_name(pod)
        if job_name not in jobs:
            jobs[job_name] = []
        else:
            jobs[job_name].append(pod)

    for job_name, pods in jobs.items():
        first_creation_timestamp = min(
            [utils.get_pod_creation_timestamp(pod) for pod in pods])
        last_finish_time = max(
            [utils.get_pod_finish_time(pod) for pod in pods])
        pod_dicts.append({
            'Task': f"{job_name}-{data_type}",
            'Start': first_creation_timestamp,
            'Finish': last_finish_time,
            'Type': data_type
        })
    return pod_dicts
コード例 #3
0
ファイル: gantt.py プロジェクト: wenshilin/k8s-benchmark
def draw_pod_gantt(pods: List[V1Pod], filename: str):
    pod_dicts = []
    colors = {}
    jobs = set()
    for pod in pods:
        job_name = utils.get_pod_job_name(pod)
        pod_dicts.append({
            'Task':
            utils.get_obj_name(pod),
            'Start':
            utils.get_pod_creation_timestamp(pod) +
            datetime.timedelta(hours=8),
            'Finish':
            utils.get_pod_finish_time(pod) + datetime.timedelta(hours=8),
            'Type':
            job_name
        })
        jobs.add(job_name)

    default_colors = py.colors.DEFAULT_PLOTLY_COLORS
    for idx, job_name in enumerate(jobs):
        colors[job_name] = default_colors[idx % len(default_colors)]

    draw_gantt(pod_dicts, colors, filename)
コード例 #4
0
from scripts.read_pod_from_file import read_pod_from_file

succeed_headers = ['名称', 'WaitTime_Scheduled(s)', 'WaitTime_Excuted(s)', 'WaitTime(s)', 'ExecutionTime(s)', 'SumTime(s)']
failed_headers = ['名称', 'Job', '提交时间', '创建时间', '开始时间', '结束时间', '负载类型', '选择调度器', '选择节点']
now = ''

pods = read_pod_from_file('../results/2020-12-08-14-01-17-边到云到边-ep.pk')

tts, succeed, failed = [], [], []
succeed_table = prettytable.PrettyTable(succeed_headers)
failed_table = prettytable.PrettyTable(failed_headers)
wait_being_created = []

pods.sort(key=lambda pod: pod.status.start_time)
for p in pods:
    submit_time = utils.get_pod_creation_timestamp(p)
    st = utils.get_pod_start_time(p)
    ft = utils.get_pod_finish_time(p)
    if utils.pod_succeeded(p):
        #ct = utils.get_pod_start_time(p)
        ct = p.status.start_time

        # waittime count
        wt = utils.get_pod_waiting_time(p)
        wt_s = utils.get_pod_beenscheduled_time(p)
        wt_e = utils.get_pod_excutedwaiting_time(p)
        wait_being_created.append(wt_e)

        rt = (ft - st).total_seconds()
        tt = wt + rt
        job = p.metadata.labels.get('job', 'None')