summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur She <arthur.she@linaro.org>2023-03-01 17:03:05 -0800
committerArthur She <arthur.she@linaro.org>2023-03-01 17:03:05 -0800
commita5a538ec379a0d305b48b13d55435df6eb57a41c (patch)
tree6a98fdbb1b4ec7b4bc397075744989d3b7c72abe
parent9970c8a862323f576c0075582a9b8941fdfe513a (diff)
draw-timestamp-chart.py: optimized loop
Signed-off-by: Arthur She <arthur.she@linaro.org>
-rwxr-xr-xdraw-timestamp-chart.py34
1 files changed, 12 insertions, 22 deletions
diff --git a/draw-timestamp-chart.py b/draw-timestamp-chart.py
index 2643a73..e87dd0f 100755
--- a/draw-timestamp-chart.py
+++ b/draw-timestamp-chart.py
@@ -125,39 +125,29 @@ if __name__ == "__main__":
num_blk = round(duration / ms_block)
start_blk = 2
a1_notation = get_a1_notation_range(1, start_blk, num_blk)
- print(a1_notation)
worksheet.format(a1_notation, colors["main"])
# Subtasks
subtasks = td["subtasks"]
row_num = 2
for i in subtasks:
- color = colors[i]
- inner_color = inner_colors[i]
subtask = subtasks[i]
# Sort the tests
tests = {k: subtask[k] for k in sorted(subtask)}
for t in tests:
- start_timestamp = tests[t]["start"]
- end_timestamp = tests[t]["end"]
- duration = end_timestamp - start_timestamp
- nr = [f"{t}\n({ms_to_hr_min(duration)})", ""]
+ test = tests[t]
+ duration = test["end"] - test["start"]
+ nr = [f"{t}\n({ms_to_hr_min(duration)})"]
task_rows.append(nr)
- first_blk = start_blk + round((start_timestamp - main_start_timestamp)/ms_block)
- num_blk = round(duration / ms_block)
- a1_notation = get_a1_notation_range(row_num, first_blk, num_blk)
- print(f"{t}: {ms_to_hr_min(duration)} / {num_blk} / {a1_notation}")
- row_format = {"range": a1_notation,
- "format": color}
- row_formats.append(row_format)
-
- if (tests[t]["innerStart"] != -1):
- first_blk = start_blk + round((tests[t]["innerStart"] - main_start_timestamp)/ms_block)
- num_blk = round((tests[t]["innerEnd"] - tests[t]["innerStart"])/ ms_block)
- a1_notation = get_a1_notation_range(row_num, first_blk, num_blk)
- row_format = {"range": a1_notation,
- "format": inner_color}
- row_formats.append(row_format)
+ keys = [["start", "end", colors], ["innerStart", "innerEnd", inner_colors]]
+ for k in keys:
+ start, end, color = k
+ if (test[start] != -1):
+ first_blk = start_blk + round((test[start] - main_start_timestamp)/ms_block)
+ num_blk = round((test[end] - test[start]) / ms_block)
+ a1_notation = get_a1_notation_range(row_num, first_blk, num_blk)
+ row_format = {"range": a1_notation, "format": color[i]}
+ row_formats.append(row_format)
row_num += 1
worksheet.append_rows(task_rows)