diff options
| -rw-r--r-- | sched_trace/draw.py | 24 | ||||
| -rwxr-xr-x | st-draw | 3 |
2 files changed, 26 insertions, 1 deletions
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 | |||
| 7 | 7 | ||
| 8 | from .format import EVENTS | 8 | from .format import EVENTS |
| 9 | 9 | ||
| 10 | from . import event_time, event_pid, event_cpu | 10 | from . import event_time, event_pid, event_cpu, event_job_id |
| 11 | 11 | ||
| 12 | ARROW_LINE_WIDTH = 2 # (pts) | 12 | ARROW_LINE_WIDTH = 2 # (pts) |
| 13 | ARROW_WIDTH = 12 # (pts) | 13 | ARROW_WIDTH = 12 # (pts) |
| @@ -60,6 +60,8 @@ TASK_LABEL_COLOR = (0, 0, 0) | |||
| 60 | TAG_FONT_SIZE = 12 | 60 | TAG_FONT_SIZE = 12 |
| 61 | TAG_COLOR = (0, 0, 0) | 61 | TAG_COLOR = (0, 0, 0) |
| 62 | 62 | ||
| 63 | JOB_ID_FONT_SIZE = 10 | ||
| 64 | |||
| 63 | GRID_WIDTH = 2 | 65 | GRID_WIDTH = 2 |
| 64 | MAJOR_TICK_WIDTH = 2 | 66 | MAJOR_TICK_WIDTH = 2 |
| 65 | MINOR_TICK_WIDTH = 1 | 67 | MINOR_TICK_WIDTH = 1 |
| @@ -84,12 +86,22 @@ def center_text(c, x, y, msg): | |||
| 84 | c.rel_move_to(-width / 2, height) | 86 | c.rel_move_to(-width / 2, height) |
| 85 | c.show_text(msg) | 87 | c.show_text(msg) |
| 86 | 88 | ||
| 89 | def center_text_above(c, x, y, msg): | ||
| 90 | x_bear, y_bear, width, height, x_adv, y_adv = c.text_extents(msg) | ||
| 91 | c.move_to(x, y) | ||
| 92 | c.rel_move_to(-width / 2, 0) | ||
| 93 | c.show_text(msg) | ||
| 94 | |||
| 87 | def text_left_align_below(c, x, y, msg): | 95 | def text_left_align_below(c, x, y, msg): |
| 88 | x_bear, y_bear, width, height, x_adv, y_adv = c.text_extents(msg) | 96 | x_bear, y_bear, width, height, x_adv, y_adv = c.text_extents(msg) |
| 89 | c.move_to(x, y) | 97 | c.move_to(x, y) |
| 90 | c.rel_move_to(0, height) | 98 | c.rel_move_to(0, height) |
| 91 | c.show_text(msg) | 99 | c.show_text(msg) |
| 92 | 100 | ||
| 101 | def text_left_align_above(c, x, y, msg): | ||
| 102 | c.move_to(x, y) | ||
| 103 | c.show_text(msg) | ||
| 104 | |||
| 93 | def vcenter_right_align_text(c, x, y, msg): | 105 | def vcenter_right_align_text(c, x, y, msg): |
| 94 | x_bear, y_bear, width, height, x_adv, y_adv = c.text_extents(msg) | 106 | x_bear, y_bear, width, height, x_adv, y_adv = c.text_extents(msg) |
| 95 | c.move_to(x, y) | 107 | c.move_to(x, y) |
| @@ -229,6 +241,7 @@ def render(opts, trace): | |||
| 229 | c.set_line_width(ARROW_LINE_WIDTH) | 241 | c.set_line_width(ARROW_LINE_WIDTH) |
| 230 | # c.set_line_cap(cairo.LINE_JOIN_ROUND) | 242 | # c.set_line_cap(cairo.LINE_JOIN_ROUND) |
| 231 | c.set_line_join(cairo.LINE_JOIN_ROUND) | 243 | c.set_line_join(cairo.LINE_JOIN_ROUND) |
| 244 | c.set_font_size(JOB_ID_FONT_SIZE) | ||
| 232 | arrow_width = ARROW_WIDTH / 2 | 245 | arrow_width = ARROW_WIDTH / 2 |
| 233 | arrow_height = ARROW_HEIGHT * YRES * yscale | 246 | arrow_height = ARROW_HEIGHT * YRES * yscale |
| 234 | for rec in trace.events_in_range_of_type(opts.start, opts.end, 'ST_RELEASE'): | 247 | for rec in trace.events_in_range_of_type(opts.start, opts.end, 'ST_RELEASE'): |
| @@ -244,6 +257,10 @@ def render(opts, trace): | |||
| 244 | c.rel_line_to(arrow_width, arrow_width) | 257 | c.rel_line_to(arrow_width, arrow_width) |
| 245 | c.stroke() | 258 | c.stroke() |
| 246 | 259 | ||
| 260 | if opts.show_job_ids: | ||
| 261 | text_left_align_above(c, rel + 4, y - arrow_height - 4, | ||
| 262 | "%d" % event_job_id(rec)) | ||
| 263 | |||
| 247 | dl = xpos(rec[-1]) | 264 | dl = xpos(rec[-1]) |
| 248 | c.new_path() | 265 | c.new_path() |
| 249 | c.move_to(dl, y - arrow_height - (GRID_WIDTH - 1)) | 266 | c.move_to(dl, y - arrow_height - (GRID_WIDTH - 1)) |
| @@ -253,6 +270,7 @@ def render(opts, trace): | |||
| 253 | c.rel_line_to(arrow_width, -arrow_width) | 270 | c.rel_line_to(arrow_width, -arrow_width) |
| 254 | c.stroke() | 271 | c.stroke() |
| 255 | 272 | ||
| 273 | |||
| 256 | if opts.verbose: | 274 | if opts.verbose: |
| 257 | print 'done.' | 275 | print 'done.' |
| 258 | print '[II] Drawing job completions...', | 276 | print '[II] Drawing job completions...', |
| @@ -270,6 +288,10 @@ def render(opts, trace): | |||
| 270 | c.rel_line_to(2 * arrow_width, 0) | 288 | c.rel_line_to(2 * arrow_width, 0) |
| 271 | c.stroke() | 289 | c.stroke() |
| 272 | 290 | ||
| 291 | if opts.show_job_ids: | ||
| 292 | text_left_align_above(c, x + 4, y - arrow_height - 4, | ||
| 293 | "%d" % event_job_id(rec)) | ||
| 294 | |||
| 273 | if opts.verbose: | 295 | if opts.verbose: |
| 274 | print 'done.' | 296 | print 'done.' |
| 275 | print '[II] Drawing job suspensions...', | 297 | print '[II] Drawing job suspensions...', |
| @@ -38,6 +38,9 @@ def parse_args(): | |||
| 38 | parser.add_argument('--minor-ticks', type=float, default=1, | 38 | parser.add_argument('--minor-ticks', type=float, default=1, |
| 39 | help="how many milliseconds per minor tick? (zero means off)") | 39 | help="how many milliseconds per minor tick? (zero means off)") |
| 40 | 40 | ||
| 41 | parser.add_argument('-j', '--show-job-ids', action='store_true', | ||
| 42 | help="show job IDs next to releases and completions") | ||
| 43 | |||
| 41 | parser.add_argument('-f', '--from', type=float, dest='start', | 44 | parser.add_argument('-f', '--from', type=float, dest='start', |
| 42 | help='draw schedule starting at time TIME', metavar='TIME') | 45 | help='draw schedule starting at time TIME', metavar='TIME') |
| 43 | parser.add_argument('-u', '--until', type=float, dest='end', | 46 | parser.add_argument('-u', '--until', type=float, dest='end', |
