sort host plane by index of xline (which is already sorted by name)
PiperOrigin-RevId: 316135421 Change-Id: Ie8d3999724c129326346a2b902d4b2d5308372b2
This commit is contained in:
parent
1e2a941351
commit
76e45e9c05
@ -50,11 +50,13 @@ void AddResourceMetadata(uint32 device_id,
|
||||
AppendEscapedName(json, resource.name());
|
||||
absl::StrAppend(json, "}},");
|
||||
}
|
||||
uint32 sort_index =
|
||||
resource.sort_index() ? resource.sort_index() : resource_id;
|
||||
absl::StrAppendFormat(
|
||||
json,
|
||||
R"({"ph":"M","pid":%u,"tid":%u,)"
|
||||
R"("name":"thread_sort_index","args":{"sort_index":%u}},)",
|
||||
device_id, resource_id, resource_id);
|
||||
device_id, resource_id, sort_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,10 +40,18 @@ Device BuildDeviceAndResource(const XPlaneVisitor& plane) {
|
||||
Device device;
|
||||
device.set_name(std::string(plane.Name()));
|
||||
device.set_device_id(plane.Id());
|
||||
|
||||
bool sort_by_ordinal = plane.Name() == kHostThreads;
|
||||
int ordinal = 0;
|
||||
plane.ForEachLine([&](const XLineVisitor& line) {
|
||||
Resource resource;
|
||||
resource.set_resource_id(line.Id());
|
||||
resource.set_name(std::string(line.Name()));
|
||||
resource.set_name(std::string(line.DisplayName()));
|
||||
if (sort_by_ordinal) {
|
||||
// When sort_index is absent (i.e. 0), resource id will be used.
|
||||
// Therefore sort_index starts with 1.
|
||||
resource.set_sort_index(++ordinal);
|
||||
}
|
||||
(*device.mutable_resources())[line.Id()] = resource;
|
||||
});
|
||||
return device;
|
||||
|
@ -40,6 +40,10 @@ message Resource {
|
||||
|
||||
// The id of the resource. Unique within a device.
|
||||
uint32 resource_id = 2;
|
||||
|
||||
// The sort index of the resource. Resources within a device are ordered by
|
||||
// this value. if absent, use resource id as sort index.
|
||||
uint32 sort_index = 3;
|
||||
}
|
||||
|
||||
message TraceEvent {
|
||||
|
Loading…
Reference in New Issue
Block a user