/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package perfetto.protos;

import "protos/perfetto/metrics/android/process_metadata.proto";

message AndroidFrameTimelineMetric {
  message JankTypeMetric {
    // The jank type
    optional string type = 1;

    // The count of frames with this jank type
    optional int64 total_count = 2;

    // The count of frames with this jank type and present type =
    // PRESENT_UNSPECIFIED
    optional int64 present_unspecified_count = 3;

    // The count of frames with this jank type and present type =
    // PRESENT_ON_TIME
    optional int64 present_on_time_count = 4;

    // The count of frames with this jank type and present type = PRESENT_LATE
    optional int64 present_late_count = 5;

    // The count of frames with this jank type and present type = PRESENT_EARLY
    optional int64 present_early_count = 6;

    // The count of frames with this jank type and present type =
    // PRESENT_DROPPED
    optional int64 present_dropped_count = 7;

    // The count of frames with this jank type and present type =
    // PRESENT_UNKNOWN
    optional int64 present_unknown_count = 8;
  }

  message ProcessBreakdown {
    optional AndroidProcessMetadata process = 3;

    optional int64 total_frames = 4;
    optional int64 missed_frames = 5;
    optional int64 missed_app_frames = 6;
    optional int64 missed_sf_frames = 7;

    optional int64 frame_dur_max = 8;
    optional int64 frame_dur_avg = 9;
    optional int64 frame_dur_p50 = 10;
    optional int64 frame_dur_p90 = 11;
    optional int64 frame_dur_p95 = 12;
    optional int64 frame_dur_p99 = 13;
    optional double frame_dur_ms_p50 = 14;
    optional double frame_dur_ms_p90 = 15;
    optional double frame_dur_ms_p95 = 16;
    optional double frame_dur_ms_p99 = 17;
    optional int64 dropped_frames = 18;

    // Metrics for each jank type in this process
    repeated JankTypeMetric jank_types = 19;

    reserved 1, 2;
  }

  optional int64 total_frames = 4;
  optional int64 missed_app_frames = 5;
  optional int64 dropped_frames = 6;

  repeated ProcessBreakdown process = 2;

  // Metrics for each jank type globally
  repeated JankTypeMetric jank_types = 7;

  reserved 1;
}
