Last active
October 14, 2021 13:32
-
-
Save LalitMaganti/c221cf0cae17e298dfa82b118edf9080 to your computer and use it in GitHub Desktop.
Perfetto Metrics Platform (demo)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Copyright 2019 Google LLC. | |
-- SPDX-License-Identifier: Apache-2.0 | |
CREATE VIEW top_five_processes_by_cpu AS | |
SELECT | |
process.name 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) | |
GROUP BY process.name | |
ORDER BY cpu_time_ms DESC | |
LIMIT 5; | |
CREATE VIEW top_five_processes_output AS | |
SELECT TopFiveProcesses( | |
'process_info', ( | |
SELECT RepeatedField( | |
ProcessInfo( | |
'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