Public
Edited
Feb 16, 2024
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
perfetto_data = {
const trackUuid = 49083589894;
const trustedPacketSequenceId = 3903809;
const processUuid = 894893984;

return {
packet: [
// ProcessDescriptor
{
trackDescriptor: {
uuid: processUuid,
process: {
pid: 1234,
processName: "My process name"
}
}
},
// ThreadDescriptor
{
trackDescriptor: {
uuid: trackUuid,
parentUuid: processUuid,
thread: {
pid: 1234,
tid: 5678,
threadName: "My thread name"
}
}
},
// slice begin
{
timestamp: 200,
trackEvent: {
type: TYPE_SLICE_BEGIN,
trackUuid,
name: "My special parent"
},
trustedPacketSequenceId
},
{
timestamp: 250,
trackEvent: {
type: TYPE_SLICE_BEGIN,
trackUuid,
name: "My special child"
},
trustedPacketSequenceId
},
// instant
{
timestamp: 285,
trackEvent: {
type: TYPE_INSTANT,
trackUuid,
name: "Instant Name",
debugAnnotations: [
{
name: "foo",
dictEntries: [
{
name: "a",
boolValue: true
},
{
name: "b",
intValue: 123
},
{
name: "ptr",
pointerValue: 123
}
]
},
{
name: "bar",
arrayValues: [
{
stringValue: "hello"
},
{
stringValue: "world"
}
]
}
]
},
trustedPacketSequenceId
},
// slice end
{
timestamp: 290,
trackEvent: {
type: TYPE_SLICE_END,
trackUuid
},
trustedPacketSequenceId
},
{
timestamp: 300,
trackEvent: {
type: TYPE_SLICE_END,
trackUuid
},
trustedPacketSequenceId
}
]
};
}
Insert cell
function encode_perfetto_trace(data) {
const Trace = root.lookupType("perfetto.protos.Trace");
const buffer = Trace.encode(data).finish();
return buffer;
}
Insert cell
function decode_perfetto_trace(buffer) {
const Trace = root.lookupType("perfetto.protos.Trace");
return Trace.decode(buffer);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
pbjs = require("protobufjs@7.2.6/dist/protobuf.min.js")
Insert cell
root = pbjs.parse(perfetto_proto).root
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more