// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Performance metrics collected via Chrome's built-in profiler.

syntax = "proto2";

option optimize_for = LITE_RUNTIME;

package metrics;


// Next tag: 4
message ProfilerEventProto {
  // The type of this profile.
  enum ProfileType {
    UNKNOWN_PROFILE = 0;  // Unknown type (should not reach here).
    STARTUP_PROFILE = 1;  // Startup profile, logged approximately 60 seconds
                          // after launch.
  }
  optional ProfileType profile_type = 1;

  // The source based upon which "time" measurements are made.
  // We currently only measure wall clock time; but we are exploring other
  // measurement sources as well, such as CPU time or TCMalloc statistics.
  enum TimeSource {
    UNKNOWN_TIME_SOURCE = 0;  // Unknown source (should not reach here).
    WALL_CLOCK_TIME = 1;      // Total time elapsed between the start and end of
                              // the task's execution.
  }
  optional TimeSource time_source = 2;

  // Data for a single tracked object (typically, a Task).
  message TrackedObject {
    // The name of the thread from which this task was posted, hashed.
    optional fixed64 birth_thread_name_hash = 1;

    // The name of the thread on which this task was executed, hashed.
    optional fixed64 exec_thread_name_hash = 2;

    // The source file name from which this task was posted, hashed.
    optional fixed64 source_file_name_hash = 3;

    // Function name from which this task was posted, hashed.
    optional fixed64 source_function_name_hash = 4;

    // The line number within the source file from which this task was posted.
    optional int32 source_line_number = 5;

    // The number of times this task was executed.
    optional int32 exec_count = 6;

    // The total execution time for instances this task.
    optional int32 exec_time_total = 7;

    // The execution time for a uniformly randomly sampled instance of this
    // task.
    optional int32 exec_time_sampled = 8;

    // The total time instances this task spent waiting (e.g. in a message loop)
    // before they were run.
    optional int32 queue_time_total = 9;

    // The time that a uniformly randomly sampled instance of this task spent
    // waiting (e.g.  in a message loop) before it was run.
    optional int32 queue_time_sampled = 10;

    // The type of process within which this task was executed.
    enum ProcessType {
      UNKNOWN = 0;  // Should not reach here
      BROWSER = 1;
      RENDERER = 2;
      PLUGIN = 3;
      WORKER = 4;
      NACL_LOADER = 5;
      UTILITY = 6;
      PROFILE_IMPORT = 7;
      ZYGOTE = 8;
      SANDBOX_HELPER = 9;
      NACL_BROKER = 10;
      GPU = 11;
      PPAPI_PLUGIN = 12;
      PPAPI_BROKER = 13;
    }
    optional ProcessType process_type = 11;

    // The local PID for the process within which this task was executed.
    optional uint32 process_id = 12;
  }
  repeated TrackedObject tracked_object = 3;
}