chromeTrace.d.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
  2. namespace ChromeTrace {
  3. interface ObjectFormat {
  4. traceEvents: ReadonlyArray<Event>;
  5. displayTimeUnit: 'ms' | 'ns';
  6. /**
  7. * Linux ftrace data or Windows ETW trace data.
  8. * This data must start with # tracer: and adhere to the
  9. * Linux ftrace format or adhere to Windows ETW format.
  10. */
  11. systemTraceEvents: string;
  12. otherData: Record<string, string>;
  13. powerTraceAsString: string;
  14. /**
  15. * string that specifies which trace data comes from tracing controller.
  16. * Its value should be the key for that specific trace data. For example,
  17. * {..., "controllerTraceDataKey": "traceEvents"} means the data for traceEvents
  18. * comes from the tracing controller. This is mainly for the purpose of clock synchronization.
  19. */
  20. controllerTraceDataKey?: string;
  21. stackFrames: ReadonlyArray<any>;
  22. samples: ReadonlyArray<any>;
  23. }
  24. type ArrayFormat = ReadonlyArray<Event>;
  25. type DurationEvent = 'B' | 'E';
  26. // Instant event
  27. type CompleteEvent = 'X';
  28. type InstantEvent = 'i';
  29. type DeprecatedInstantEvent = 'I';
  30. type CounterEvent = 'C';
  31. // b = nestable start, n = nestable instant, e = nestable end
  32. type AsyncEvent = 'b' | 'n' | 'e';
  33. // S = start, T = step into, p = step past, F = end
  34. type DeprecatedAsyncEvent = 'S' | 'T' | 'p' | 'F';
  35. // s = start, t = step, f = end
  36. type FlowEvent = 's' | 't' | 'f';
  37. type SampleEvent = 'P';
  38. // N = created, O = snapshot, D = destroyed
  39. type ObjectEvent = 'N' | 'O' | 'D';
  40. type MetadataEvent = 'M';
  41. // V = global, v = process
  42. type MemoryDumpEvent = 'V' | 'v';
  43. type MarkEvent = 'R';
  44. type ClockSyncEvent = 'c';
  45. type ContextEvents = '(,)';
  46. interface Event {
  47. name: string;
  48. cat: string;
  49. ph:
  50. | DurationEvent
  51. | CompleteEvent
  52. | InstantEvent
  53. | DeprecatedInstantEvent
  54. | CounterEvent
  55. | AsyncEvent
  56. | DeprecatedAsyncEvent
  57. | FlowEvent
  58. | SampleEvent
  59. | ObjectEvent
  60. | MetadataEvent
  61. | MemoryDumpEvent
  62. | MarkEvent
  63. | ClockSyncEvent
  64. | ContextEvents;
  65. ts: number;
  66. // Thread clock timestamp
  67. tts?: number;
  68. dur?: number;
  69. tdur?: number;
  70. pid: number;
  71. tid: number;
  72. cname?: string;
  73. args: Record<string, any | Record<string, any>>;
  74. }
  75. // https://github.com/v8/v8/blob/b8626ca445554b8376b5a01f651b70cb8c01b7dd/src/inspector/js_protocol.json#L1399
  76. interface ProfileNode {
  77. id: number;
  78. callFrame: CPUProfileCallFrame;
  79. hitCount: number;
  80. children?: number[];
  81. parent?: CPUProfileNode;
  82. deoptReason?: string;
  83. positionTicks?: PositionTickInfo[];
  84. }
  85. // https://github.com/v8/v8/blob/b8626ca445554b8376b5a01f651b70cb8c01b7dd/src/inspector/js_protocol.json#L1453
  86. interface Profile {
  87. nodes: ProfileNode[];
  88. startTime: number;
  89. endTime: number;
  90. samples?: number[];
  91. timeDeltas?: number[];
  92. }
  93. type ProfileType = ArrayFormat | ObjectFormat;
  94. }