Update timing dump and tools
This commit is contained in:
committed by
Guillaume Meunier
parent
7e22b3fa92
commit
1792607ada
@@ -114,7 +114,7 @@ void VideoEncoder::SendData(std::span<uint8_t> data, bool end_of_frame)
|
||||
debug.write((char*)data.data(), data.size());
|
||||
#endif
|
||||
if (shard.shard_idx == 0)
|
||||
cnx->dump_time("send_start", shard.frame_idx, os_monotonic_get_ns(), stream_idx);
|
||||
cnx->dump_time("send_begin", shard.frame_idx, os_monotonic_get_ns(), stream_idx);
|
||||
|
||||
shard.flags = to_headset::video_stream_data_shard::start_of_slice;
|
||||
auto begin = data.begin();
|
||||
@@ -137,6 +137,8 @@ void VideoEncoder::SendData(std::span<uint8_t> data, bool end_of_frame)
|
||||
shard.view_info.reset();
|
||||
begin = next;
|
||||
}
|
||||
if (end_of_frame)
|
||||
cnx->dump_time("send_end", shard.frame_idx, os_monotonic_get_ns(), stream_idx);
|
||||
}
|
||||
|
||||
} // namespace xrt::drivers::wivrn
|
||||
|
||||
@@ -208,11 +208,11 @@ void wivrn_session::operator()(from_headset::feedback && feedback)
|
||||
comp_target->on_feedback(feedback, o);
|
||||
|
||||
if (feedback.received_first_packet)
|
||||
dump_time("receive_start", feedback.frame_index, o.from_headset(feedback.received_first_packet), feedback.stream_index);
|
||||
dump_time("receive_begin", feedback.frame_index, o.from_headset(feedback.received_first_packet), feedback.stream_index);
|
||||
if (feedback.received_last_packet)
|
||||
dump_time("receive_end", feedback.frame_index, o.from_headset(feedback.received_last_packet), feedback.stream_index);
|
||||
if (feedback.sent_to_decoder)
|
||||
dump_time("decode_start", feedback.frame_index, o.from_headset(feedback.sent_to_decoder), feedback.stream_index);
|
||||
dump_time("decode_begin", feedback.frame_index, o.from_headset(feedback.sent_to_decoder), feedback.stream_index);
|
||||
if (feedback.received_from_decoder)
|
||||
dump_time("decode_end", feedback.frame_index, o.from_headset(feedback.received_from_decoder), feedback.stream_index);
|
||||
if (feedback.blitted)
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import csv
|
||||
import argparse
|
||||
|
||||
PIXEL_SCALE = 10/1_000_000 # 10px/ms
|
||||
LINE_HEIGHT = 10
|
||||
|
||||
COLOURS = ["#ea5545", "#f46a9b", "#ef9b20", "#edbf33", "#ede15b", "#bdcf32", "#87bc45", "#27aeef", "#b33dc6"]
|
||||
|
||||
class Frame:
|
||||
def __init__(self, num):
|
||||
@@ -45,98 +39,6 @@ class Frame:
|
||||
return None
|
||||
|
||||
|
||||
def draw(self, out):
|
||||
out.write("<!-- frame {} -->\n".format(self.num))
|
||||
if "wake_up" in self.events and "submit" in self.events:
|
||||
wake_up = self.events["wake_up"]
|
||||
submit = self.events["submit"]
|
||||
out.write('<rect x="{x}" y="{y}" width="{w}" height="{h}" fill="{fill}" class="compositor"/>\n'.format(
|
||||
x = wake_up * PIXEL_SCALE,
|
||||
w = (submit - wake_up) * PIXEL_SCALE,
|
||||
y = 0,
|
||||
h = LINE_HEIGHT,
|
||||
fill = COLOURS[0]
|
||||
))
|
||||
if "begin" in self.events:
|
||||
begin = self.events["begin"]
|
||||
out.write('<line x1="{x}" y1="{y}" x2="{x}" y2="{y2}" class="begin"/>\n'.format(
|
||||
x = begin * PIXEL_SCALE,
|
||||
y = 0,
|
||||
y2 = LINE_HEIGHT
|
||||
))
|
||||
|
||||
for stream, events in self.streams.items():
|
||||
y_offset = LINE_HEIGHT * (1 + stream * 2)
|
||||
if "encode_begin" in events and "rs_end" in events:
|
||||
begin = events["encode_begin"]
|
||||
end = events["encode_end"]
|
||||
send_start = events["send_start"]
|
||||
rs_end = events["rs_end"]
|
||||
out.write('<rect x="{x}" y="{y}" width="{w}" height="{h}" fill="{fill}" class="encode"/>\n'.format(
|
||||
x = begin * PIXEL_SCALE,
|
||||
y = y_offset,
|
||||
h = LINE_HEIGHT,
|
||||
w = (end - begin) * PIXEL_SCALE,
|
||||
fill = COLOURS[1]
|
||||
))
|
||||
out.write('<rect x="{x}" y="{y}" width="{w}" height="{h}" fill="{fill}" class="send"/>\n'.format(
|
||||
x = send_start * PIXEL_SCALE,
|
||||
y = y_offset + 0.2 * LINE_HEIGHT,
|
||||
h = 0.6 * LINE_HEIGHT,
|
||||
w = (rs_end - send_start) * PIXEL_SCALE,
|
||||
fill = COLOURS[2]
|
||||
))
|
||||
|
||||
y_offset = LINE_HEIGHT * (2 + stream * 2)
|
||||
|
||||
if "receive_start" in events and "receive_end" in events:
|
||||
begin = events["receive_start"]
|
||||
end = events["receive_end"]
|
||||
out.write('<rect x="{x}" y="{y}" width="{w}" height="{h}" fill="{fill}" class="receive"/>\n'.format(
|
||||
x = begin * PIXEL_SCALE,
|
||||
y = y_offset,
|
||||
h = LINE_HEIGHT,
|
||||
w = (end - begin) * PIXEL_SCALE,
|
||||
fill = COLOURS[3]
|
||||
))
|
||||
|
||||
if "reconstructed" in events:
|
||||
t = events["reconstructed"]
|
||||
out.write('<line x1="{x}" y1="{y}" x2="{x}" y2="{y2}" class="reconstructed"/>\n'.format(
|
||||
x = t * PIXEL_SCALE,
|
||||
y = y_offset,
|
||||
y2 = y_offset + LINE_HEIGHT
|
||||
))
|
||||
|
||||
if "decode_start" in events and "decode_end" in events:
|
||||
begin = events["decode_start"]
|
||||
end = events["decode_end"]
|
||||
out.write('<rect x="{x}" y="{y}" width="{w}" height="{h}" fill="{fill}" class="decode"/>\n'.format(
|
||||
x = begin * PIXEL_SCALE,
|
||||
y = y_offset,
|
||||
h = LINE_HEIGHT,
|
||||
w = (end - begin) * PIXEL_SCALE,
|
||||
fill = COLOURS[4]
|
||||
))
|
||||
|
||||
if "blit" in events:
|
||||
t = events["blit"]
|
||||
out.write('<line x1="{x}" y1="{y}" x2="{x}" y2="{y2}" stroke="{stroke}" class="blit"/>\n'.format(
|
||||
x = t * PIXEL_SCALE,
|
||||
y = y_offset,
|
||||
y2 = y_offset + LINE_HEIGHT,
|
||||
stroke = COLOURS[0]
|
||||
))
|
||||
|
||||
if "display" in events:
|
||||
t = events["display"]
|
||||
out.write('<line x1="{x}" y1="{y}" x2="{x}" y2="{y2}" stroke="{stroke}" class="display"/>\n'.format(
|
||||
x = t * PIXEL_SCALE,
|
||||
y = y_offset,
|
||||
y2 = y_offset + LINE_HEIGHT,
|
||||
stroke = COLOURS[1]
|
||||
))
|
||||
|
||||
def read(file, skip=0, duration_ms=-1):
|
||||
timings = csv.reader(file)
|
||||
|
||||
@@ -176,25 +78,3 @@ def durations(frames, stream=None, flag=None, *args, **kwargs):
|
||||
return flag in frame.flags.get(stream, ())
|
||||
res = [frame.duration(*args, **kwargs) for frame in frames if filter(frame)]
|
||||
return [d for d in res if d is not None]
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser("Parser for WiVRn timing dumps")
|
||||
parser.add_argument("CSV", type=argparse.FileType("r"))
|
||||
parser.add_argument("--out", type=argparse.FileType("w"), default="-")
|
||||
parser.add_argument("--skip", type=int, default=0)
|
||||
parser.add_argument("--duration_ms", type=int, default=-1)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
frames = read(args.CSV, args.skip, args.duration_ms)
|
||||
|
||||
out = args.out
|
||||
out.write('''<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
''')
|
||||
|
||||
for frame in reversed(frames):
|
||||
frame.draw(out)
|
||||
|
||||
out.write("</svg>")
|
||||
|
||||
+40
-46
@@ -20,7 +20,7 @@ function load_timings(filename)
|
||||
for(let i in lines)
|
||||
{
|
||||
items = lines[i].split(',');
|
||||
if (items.length != 4)
|
||||
if (items.length < 4)
|
||||
continue;
|
||||
|
||||
event_name = items[0].replaceAll('"', '');
|
||||
@@ -64,13 +64,13 @@ function load_timings(filename)
|
||||
|
||||
for(let i in timing_data)
|
||||
{
|
||||
var frame_start = Number.MAX_VALUE;
|
||||
var frame_begin = Number.MAX_VALUE;
|
||||
var frame_end = -Number.MAX_VALUE;
|
||||
for(let j in timing_data[i])
|
||||
{
|
||||
for(let k in timing_data[i][j])
|
||||
{
|
||||
frame_start = Math.min(frame_start, timing_data[i][j][k]);
|
||||
frame_begin = Math.min(frame_begin, timing_data[i][j][k]);
|
||||
frame_end = Math.max(frame_end, timing_data[i][j][k]);
|
||||
}
|
||||
}
|
||||
@@ -79,11 +79,11 @@ function load_timings(filename)
|
||||
{
|
||||
for(let k in timing_data[i][j])
|
||||
{
|
||||
timing_data[i][j][k] = (timing_data[i][j][k] - frame_start) / 1000000; // nanoseconds to milliseconds
|
||||
timing_data[i][j][k] = (timing_data[i][j][k] - frame_begin) / 1000000; // nanoseconds to milliseconds
|
||||
}
|
||||
}
|
||||
|
||||
timing_data[i].global.frame_start = (frame_start - min_timestamp) / 1000000;
|
||||
timing_data[i].global.frame_begin = (frame_begin - min_timestamp) / 1000000;
|
||||
timing_data[i].global.frame_end = (frame_end - min_timestamp) / 1000000;
|
||||
}
|
||||
|
||||
@@ -131,8 +131,8 @@ function draw_frame(svg, frame_id, frame_data, t_offset, t_scale, line_height, l
|
||||
if (!("wake_up" in frame_data["global"]) || !("submit" in frame_data["global"]))
|
||||
return;
|
||||
|
||||
const t0 = frame_data.global.frame_start;
|
||||
g.frame_start = frame_data.global.frame_start;
|
||||
const t0 = frame_data.global.frame_begin;
|
||||
g.frame_begin = frame_data.global.frame_begin;
|
||||
g.setAttribute("transform", "translate(" + ((t0-t_offset) * t_scale) + " 0)");
|
||||
g.setAttribute("id", frame_id);
|
||||
g.setAttribute("class", 'frame');
|
||||
@@ -170,54 +170,54 @@ function draw_frame(svg, frame_id, frame_data, t_offset, t_scale, line_height, l
|
||||
|
||||
const events = frame_data[stream];
|
||||
|
||||
var encode_start = 0;
|
||||
var encode_begin = 0;
|
||||
var encode_end = 0;
|
||||
var send_start = 0;
|
||||
var send_begin = 0;
|
||||
var send_end = 0;
|
||||
var receive_start = 0;
|
||||
var receive_begin = 0;
|
||||
var receive_end = 0;
|
||||
var reconstructed = 0;
|
||||
var decode_start = 0;
|
||||
var decode_begin = 0;
|
||||
var decode_end = 0;
|
||||
var blit = 0;
|
||||
var display = 0;
|
||||
|
||||
if (("encode_begin" in events) && ("rs_end" in events))
|
||||
if (("encode_begin" in events) && ("send_end" in events))
|
||||
{
|
||||
encode_start = events["encode_begin"];
|
||||
encode_begin = events["encode_begin"];
|
||||
encode_end = events["encode_end"];
|
||||
send_start = events["send_start"];
|
||||
send_end = events["rs_end"];
|
||||
send_begin = events["send_begin"];
|
||||
send_end = events["send_end"];
|
||||
|
||||
var encode = document.createElementNS("http://www.w3.org/2000/svg", 'rect');
|
||||
encode.setAttribute('x', encode_start * t_scale);
|
||||
encode.setAttribute('x', encode_begin * t_scale);
|
||||
encode.setAttribute('y', y0);
|
||||
encode.setAttribute('width', (encode_end - encode_start) * t_scale);
|
||||
encode.setAttribute('width', (encode_end - encode_begin) * t_scale);
|
||||
encode.setAttribute('height', line_height);
|
||||
encode.setAttribute('fill', colours[1]);
|
||||
encode.setAttribute('class', 'encode');
|
||||
|
||||
var text1 = document.createElementNS("http://www.w3.org/2000/svg", 'text');
|
||||
text1.setAttribute('x', encode_start * t_scale);
|
||||
text1.setAttribute('x', encode_begin * t_scale);
|
||||
text1.setAttribute('y', y0 + line_height / 2);
|
||||
text1.setAttribute('dominant-baseline', 'middle');
|
||||
text1.setAttribute('text-anchor', 'left');
|
||||
text1.innerHTML = '+' + encode_start.toFixed(2) + ' ms';
|
||||
text1.innerHTML = '+' + encode_begin.toFixed(2) + ' ms';
|
||||
|
||||
var send = document.createElementNS("http://www.w3.org/2000/svg", 'rect');
|
||||
send.setAttribute('x', send_start * t_scale);
|
||||
send.setAttribute('x', send_begin * t_scale);
|
||||
send.setAttribute('y', y0 + line_height * 0.2);
|
||||
send.setAttribute('width', (send_end - send_start) * t_scale);
|
||||
send.setAttribute('width', (send_end - send_begin) * t_scale);
|
||||
send.setAttribute('height', line_height * 0.6);
|
||||
send.setAttribute('fill', colours[2]);
|
||||
send.setAttribute('class', 'send');
|
||||
|
||||
var text2 = document.createElementNS("http://www.w3.org/2000/svg", 'text');
|
||||
text2.setAttribute('x', send_start * t_scale);
|
||||
text2.setAttribute('x', send_begin * t_scale);
|
||||
text2.setAttribute('y', y0 + line_height / 2);
|
||||
text2.setAttribute('dominant-baseline', 'middle');
|
||||
text2.setAttribute('text-anchor', 'left');
|
||||
text2.innerHTML = '+' + send_start.toFixed(2) + ' ms';
|
||||
text2.innerHTML = '+' + send_begin.toFixed(2) + ' ms';
|
||||
|
||||
y0 = y0 + dy;
|
||||
|
||||
@@ -231,23 +231,23 @@ function draw_frame(svg, frame_id, frame_data, t_offset, t_scale, line_height, l
|
||||
continue;
|
||||
}
|
||||
|
||||
if (("receive_start" in events) && ("receive_end" in events))
|
||||
if (("receive_begin" in events) && ("receive_end" in events))
|
||||
{
|
||||
receive_start = events["receive_start"];
|
||||
receive_begin = events["receive_begin"];
|
||||
receive_end = events["receive_end"];
|
||||
|
||||
var receive = document.createElementNS("http://www.w3.org/2000/svg", 'rect');
|
||||
receive.setAttribute('x', receive_start * t_scale);
|
||||
receive.setAttribute('x', receive_begin * t_scale);
|
||||
receive.setAttribute('y', y0);
|
||||
receive.setAttribute('width', Math.max(1, (receive_end - receive_start) * t_scale));
|
||||
receive.setAttribute('width', Math.max(1, (receive_end - receive_begin) * t_scale));
|
||||
receive.setAttribute('height', line_height);
|
||||
receive.setAttribute('fill', colours[3]);
|
||||
receive.setAttribute('class', 'receive');
|
||||
|
||||
var path = document.createElementNS("http://www.w3.org/2000/svg", 'path');
|
||||
const x1 = send_start * t_scale + 0.5;
|
||||
const x1 = send_begin * t_scale + 0.5;
|
||||
const y1 = y0 - dy + line_height;
|
||||
const x2 = receive_start * t_scale + 0.5;
|
||||
const x2 = receive_begin * t_scale + 0.5;
|
||||
const y2 = y0;
|
||||
path.setAttribute('d', 'M ' + x1 + ' ' + y1 + ' C ' + x1 + ' ' + y2 + ',' + x2 + ' ' + y1 + ',' + x2 + ' ' + y2);
|
||||
path.setAttribute('stroke', '#000000');
|
||||
@@ -261,30 +261,25 @@ function draw_frame(svg, frame_id, frame_data, t_offset, t_scale, line_height, l
|
||||
continue;
|
||||
}
|
||||
|
||||
if ("reconstructed" in events)
|
||||
if (("decode_begin" in events) && ("decode_end" in events))
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
if (("decode_start" in events) && ("decode_end" in events))
|
||||
{
|
||||
decode_start = events["decode_start"];
|
||||
decode_begin = events["decode_begin"];
|
||||
decode_end = events["decode_end"];
|
||||
|
||||
var decode = document.createElementNS("http://www.w3.org/2000/svg", 'rect');
|
||||
decode.setAttribute('x', decode_start * t_scale);
|
||||
decode.setAttribute('x', decode_begin * t_scale);
|
||||
decode.setAttribute('y', y0);
|
||||
decode.setAttribute('width', (decode_end - decode_start)* t_scale);
|
||||
decode.setAttribute('width', (decode_end - decode_begin)* t_scale);
|
||||
decode.setAttribute('height', line_height);
|
||||
decode.setAttribute('fill', colours[5]);
|
||||
decode.setAttribute('class', 'decode');
|
||||
|
||||
var text = document.createElementNS("http://www.w3.org/2000/svg", 'text');
|
||||
text.setAttribute('x', receive_start * t_scale);
|
||||
text.setAttribute('x', receive_begin * t_scale);
|
||||
text.setAttribute('y', y0 + line_height / 2);
|
||||
text.setAttribute('dominant-baseline', 'middle');
|
||||
text.setAttribute('text-anchor', 'left');
|
||||
text.innerHTML = '+' + receive_start.toFixed(2) + ' ms';
|
||||
text.innerHTML = '+' + receive_begin.toFixed(2) + ' ms';
|
||||
|
||||
y0 = y0 + dy;
|
||||
|
||||
@@ -410,17 +405,16 @@ function draw_everything(svg, timing_data)
|
||||
}
|
||||
|
||||
svg.t0 = 0;
|
||||
svg.frames = document.getElementsByClassName('frame');
|
||||
|
||||
svg.addEventListener('wheel', (event) => {
|
||||
event.preventDefault();
|
||||
frames = svg.getElementsByClassName('frame');
|
||||
|
||||
svg.t0 = Math.max(0, svg.t0 + event.deltaY * 0.1);
|
||||
const t_offset = svg.t0;
|
||||
for(let i in svg.frames)
|
||||
{
|
||||
const t0 = svg.frames[i].frame_start;
|
||||
svg.frames[i].setAttribute("transform", "translate(" + ((t0-t_offset) * t_scale) + " 0)");
|
||||
}
|
||||
Array.from(frames).forEach((frame) => {
|
||||
const t0 = frame.frame_begin;
|
||||
frame.setAttribute("transform", "translate(" + ((t0-t_offset) * t_scale) + " 0)");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user