Commit 7fca98e8 authored by Deepanjan Roy's avatar Deepanjan Roy Committed by Commit Bot

[tbmv3] Convert CPU time metric to TBMv3

This metric corresponds to the current TBMv2 CPU time metric.
See https://source.chromium.org/chromium/chromium/src/+/master:third_party/catapult/tracing/tracing/metrics/system_health/cpu_time_metric.html

Bug: 1096236
Change-Id: Ib922da8032724992ac243e87d8b5e3497ac3d912
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2250946
Commit-Queue: Deep Roy <dproy@chromium.org>
Reviewed-by: default avatarMikhail Khokhlov <khokhlov@google.com>
Cr-Commit-Position: refs/heads/master@{#779939}
parent 705238a4
// Copyright 2020 Google LLC.
// SPDX-License-Identifier: Apache-2.0
syntax = "proto2";
package perfetto.protos;
import "protos/perfetto/metrics/metrics.proto";
import "protos/perfetto/metrics/custom_options.proto";
message CpuTimeMetric {
optional double cpu_time_percentage = 1 [(unit) = "n%_smallerIsBetter"];
}
extend TraceMetrics {
optional CpuTimeMetric cpu_time_metric = 460;
}
-- Copyright 2020 Google LLC.
-- SPDX-License-Identifier: Apache-2.0
-- First create a view that exposes cpu time of all slices.
-- TODO(dproy): Extract this view into a common helper file.
CREATE VIEW cpu_slices
AS
SELECT
slice.id,
slice.name AS slice_name,
slice.ts,
slice.dur,
slice.depth AS depth,
thread_counter_track.id AS counter_track_id,
(
SELECT max(value)
FROM counter
WHERE ts = slice.ts AND track_id = thread_counter_track.id
) AS cpu_start,
(
SELECT max(value)
FROM counter
WHERE ts = (slice.ts + slice.dur) AND track_id = thread_counter_track.id
) AS cpu_end
FROM slice
INNER JOIN thread_track ON slice.track_id = thread_track.id
INNER JOIN thread_counter_track ON thread_track.utid = thread_counter_track.utid
WHERE slice.dur >= 0;
-- Sum over the cpu time of top level slices (slices with depth 0).
CREATE VIEW total_cpu_time
AS SELECT sum(cpu_end - cpu_start) AS total_cpu FROM cpu_slices WHERE depth = 0;
CREATE VIEW cpu_time_metric
AS
SELECT
cast((SELECT total_cpu FROM total_cpu_time) AS float)
/ (SELECT (end_ts - start_ts) FROM trace_bounds) AS cpu_time_percentage;
CREATE VIEW cpu_time_metric_output
AS
SELECT CpuTimeMetric('cpu_time_percentage', cpu_time_percentage)
FROM cpu_time_metric;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment