From 2f0330ee24d4fa827cfd56e16bd3ae34b703a9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Brandenburg?= Date: Thu, 24 Mar 2016 14:07:41 +0100 Subject: st-draw: optionally include job IDs --- sched_trace/draw.py | 24 +++++++++++++++++++++++- st-draw | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/sched_trace/draw.py b/sched_trace/draw.py index 273e17b..4a0386e 100644 --- a/sched_trace/draw.py +++ b/sched_trace/draw.py @@ -7,7 +7,7 @@ from math import ceil from .format import EVENTS -from . import event_time, event_pid, event_cpu +from . import event_time, event_pid, event_cpu, event_job_id ARROW_LINE_WIDTH = 2 # (pts) ARROW_WIDTH = 12 # (pts) @@ -60,6 +60,8 @@ TASK_LABEL_COLOR = (0, 0, 0) TAG_FONT_SIZE = 12 TAG_COLOR = (0, 0, 0) +JOB_ID_FONT_SIZE = 10 + GRID_WIDTH = 2 MAJOR_TICK_WIDTH = 2 MINOR_TICK_WIDTH = 1 @@ -84,12 +86,22 @@ def center_text(c, x, y, msg): c.rel_move_to(-width / 2, height) c.show_text(msg) +def center_text_above(c, x, y, msg): + x_bear, y_bear, width, height, x_adv, y_adv = c.text_extents(msg) + c.move_to(x, y) + c.rel_move_to(-width / 2, 0) + c.show_text(msg) + def text_left_align_below(c, x, y, msg): x_bear, y_bear, width, height, x_adv, y_adv = c.text_extents(msg) c.move_to(x, y) c.rel_move_to(0, height) c.show_text(msg) +def text_left_align_above(c, x, y, msg): + c.move_to(x, y) + c.show_text(msg) + def vcenter_right_align_text(c, x, y, msg): x_bear, y_bear, width, height, x_adv, y_adv = c.text_extents(msg) c.move_to(x, y) @@ -229,6 +241,7 @@ def render(opts, trace): c.set_line_width(ARROW_LINE_WIDTH) # c.set_line_cap(cairo.LINE_JOIN_ROUND) c.set_line_join(cairo.LINE_JOIN_ROUND) + c.set_font_size(JOB_ID_FONT_SIZE) arrow_width = ARROW_WIDTH / 2 arrow_height = ARROW_HEIGHT * YRES * yscale for rec in trace.events_in_range_of_type(opts.start, opts.end, 'ST_RELEASE'): @@ -244,6 +257,10 @@ def render(opts, trace): c.rel_line_to(arrow_width, arrow_width) c.stroke() + if opts.show_job_ids: + text_left_align_above(c, rel + 4, y - arrow_height - 4, + "%d" % event_job_id(rec)) + dl = xpos(rec[-1]) c.new_path() c.move_to(dl, y - arrow_height - (GRID_WIDTH - 1)) @@ -253,6 +270,7 @@ def render(opts, trace): c.rel_line_to(arrow_width, -arrow_width) c.stroke() + if opts.verbose: print 'done.' print '[II] Drawing job completions...', @@ -270,6 +288,10 @@ def render(opts, trace): c.rel_line_to(2 * arrow_width, 0) c.stroke() + if opts.show_job_ids: + text_left_align_above(c, x + 4, y - arrow_height - 4, + "%d" % event_job_id(rec)) + if opts.verbose: print 'done.' print '[II] Drawing job suspensions...', diff --git a/st-draw b/st-draw index 45b96f1..afffd0b 100755 --- a/st-draw +++ b/st-draw @@ -38,6 +38,9 @@ def parse_args(): parser.add_argument('--minor-ticks', type=float, default=1, help="how many milliseconds per minor tick? (zero means off)") + parser.add_argument('-j', '--show-job-ids', action='store_true', + help="show job IDs next to releases and completions") + parser.add_argument('-f', '--from', type=float, dest='start', help='draw schedule starting at time TIME', metavar='TIME') parser.add_argument('-u', '--until', type=float, dest='end', -- cgit v1.2.2