Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Perfetto Metrics Platform (demo)
// Copyright 2019 Google LLC.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto2";
package perfetto.protos;
import "protos/perfetto/metrics/metrics.proto";
message ProcessInfo {
optional string process_name = 1;
optional int64 cpu_time_ms = 2;
optional uint32 num_threads = 3;
message TopFiveProcesses {
repeated ProcessInfo process_info = 1;
extend TraceMetrics {
optional TopFiveProcesses top_five_processes = 450;
-- Copyright 2019 Google LLC.
-- SPDX-License-Identifier: Apache-2.0
CREATE VIEW top_five_processes_by_cpu AS
SELECT as process_name,
CAST(SUM(sched.dur) / 1e6 as INT64) as cpu_time_ms,
COUNT(DISTINCT utid) as num_threads
FROM sched
INNER JOIN thread USING(utid)
INNER JOIN process USING(upid)
ORDER BY cpu_time_ms DESC
CREATE VIEW top_five_processes_output AS
SELECT TopFiveProcesses(
'process_info', (
SELECT RepeatedField(
'process_name', process_name,
'cpu_time_ms', cpu_time_ms,
'num_threads', num_threads
FROM top_five_processes_by_cpu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment