diff options
author | Arthur She <arthur.she@linaro.org> | 2023-03-16 13:38:32 -0700 |
---|---|---|
committer | Arthur She <arthur.she@linaro.org> | 2023-03-16 13:38:32 -0700 |
commit | 9e22e8c37f647138ac3f7687f6692439c2fdafd2 (patch) | |
tree | 35e60ac3f93e3fe1b97b24e46d9e0116517612fa | |
parent | 127b5220cbe716a1b650111e9f7f090aa5ee4352 (diff) |
draw-timestamp-chart.py: Calculate subtask duration
Signed-off-by: Arthur She <arthur.she@linaro.org>
-rwxr-xr-x | draw-timestamp-chart.py | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/draw-timestamp-chart.py b/draw-timestamp-chart.py index 5d5d4d0..c5068e5 100755 --- a/draw-timestamp-chart.py +++ b/draw-timestamp-chart.py @@ -27,6 +27,10 @@ inner_colors = {"main": {"backgroundColor": {"red": 0.63, "green": "freebsd": {"backgroundColor": {"red": 0, "green": 1, "blue": 1}}, "dockerfile-builder": {"backgroundColor": {"red": 0.27, "green": 0.5, "blue": 0.55}}} +subtask_mapping = {"windows": "Windows", + "container-host": "Linux", + "freebsd": "FreeBSD"} + min_block = 3 # Minute per block ms_block = (min_block * 60 * 1000) # milli second per block task_rows = [] @@ -35,7 +39,7 @@ row_formats = [] def create_worksheet(spreadsheet, job_name): # Add a new worksheet try: - worksheet = spreadsheet.add_worksheet(job_name, 185, 500) + worksheet = spreadsheet.add_worksheet(job_name, 190, 500) except: print(f"worksheet {job_name} is already exist") sys.exit(1) @@ -65,10 +69,29 @@ def create_worksheet(spreadsheet, job_name): 'endIndex': 1 }, 'properties': { - 'pixelSize': 200 + 'pixelSize': 250 }, 'fields': 'pixelSize' } + }, + { + "repeatCell": { + "range": { + "sheetId": worksheet.id, + "startRowIndex": 0, + "endRowIndex": 190, + "startColumnIndex": 0, + "endColumnIndex": 190 + }, + "cell": { + "userEnteredFormat": { + "textFormat": { + "fontSize": 7 + } + } + }, + "fields": "userEnteredFormat(textFormat(fontSize))" + } } ] @@ -134,7 +157,7 @@ if __name__ == "__main__": main_start_timestamp = td["main"][main_task]["start"] end_timestamp = td["main"][main_task]["end"] duration = end_timestamp - main_start_timestamp - new_row = [f"{main_task}\n({ms_to_hr_min(duration)})", ""] + new_row = [f"{main_task}\n(Total: {ms_to_hr_min(duration)}"] updated_row = worksheet.append_row(new_row) num_blk = round(duration / ms_block) start_blk = 2 @@ -144,12 +167,17 @@ if __name__ == "__main__": subtasks = td["subtasks"] row_num = 2 keys = [["start", "end", colors], ["innerStart", "innerEnd", inner_colors]] + st_duration = {} for i in subtasks: subtask = subtasks[i] # Sort the tests tests = {k: subtask[k] for k in sorted(subtask)} + s_start = end_timestamp + s_end = main_start_timestamp for t in tests: test = tests[t] + s_start = test["start"] if test["start"] < s_start else s_start + s_end = test["end"] if test["end"] > s_end else s_end duration = test["end"] - test["start"] inner_duration = test["innerEnd"] - test["innerStart"] nr = [f"{t}\n(Total: {ms_to_hr_min(duration)} / Test: {ms_to_hr_min(inner_duration)})"] @@ -165,5 +193,14 @@ if __name__ == "__main__": row_formats.append(row_format) row_num += 1 + st_duration[i] = {"start": s_start, "end": s_end, "duration": ms_to_hr_min(s_end - s_start)} + print(st_duration) + main_str = worksheet.get("A1")[0][0] + for i in st_duration: + if i in subtask_mapping: + main_str += f" / {subtask_mapping[i]}: {st_duration[i]['duration']}" + main_str += ')' + print(main_str) + worksheet.update_cell(1, 1, main_str) worksheet.append_rows(task_rows) worksheet.batch_format(row_formats) |