@paulirish/trace_engine 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/analyze-trace.mjs +1 -1
  2. package/core/platform/DevToolsPath.d.ts +23 -0
  3. package/core/platform/DevToolsPath.js +7 -0
  4. package/core/platform/DevToolsPath.js.map +1 -0
  5. package/core/platform/MimeType.d.ts +27 -0
  6. package/core/platform/MimeType.js +137 -0
  7. package/core/platform/MimeType.js.map +1 -0
  8. package/core/platform/Timing.d.ts +7 -0
  9. package/core/platform/Timing.js +13 -0
  10. package/core/platform/Timing.js.map +1 -0
  11. package/core/platform/UIString.d.ts +3 -0
  12. package/core/platform/UIString.js +5 -0
  13. package/core/platform/UIString.js.map +1 -0
  14. package/core/platform/UserVisibleError.d.ts +12 -0
  15. package/core/platform/UserVisibleError.js +23 -0
  16. package/core/platform/UserVisibleError.js.map +1 -0
  17. package/core/platform/array-utilities.d.ts +66 -0
  18. package/core/platform/array-utilities.js +199 -0
  19. package/core/platform/array-utilities.js.map +1 -0
  20. package/core/platform/brand.d.ts +14 -0
  21. package/core/platform/brand.js +5 -0
  22. package/core/platform/brand.js.map +1 -0
  23. package/core/platform/bundle-tsconfig.json +1 -0
  24. package/core/platform/date-utilities.d.ts +2 -0
  25. package/core/platform/date-utilities.js +14 -0
  26. package/core/platform/date-utilities.js.map +1 -0
  27. package/core/platform/dcheck-tsconfig.json +8 -0
  28. package/core/platform/dcheck.d.ts +4 -0
  29. package/core/platform/dcheck.js +5 -0
  30. package/core/platform/devtools_entrypoint-bundle-tsconfig-tsconfig.json +40 -0
  31. package/core/platform/devtools_entrypoint-bundle-typescript-tsconfig.json +44 -0
  32. package/core/platform/dom-utilities.d.ts +8 -0
  33. package/core/platform/dom-utilities.js +109 -0
  34. package/core/platform/dom-utilities.js.map +1 -0
  35. package/core/platform/keyboard-utilities.d.ts +17 -0
  36. package/core/platform/keyboard-utilities.js +22 -0
  37. package/core/platform/keyboard-utilities.js.map +1 -0
  38. package/core/platform/map-utilities.d.ts +18 -0
  39. package/core/platform/map-utilities.js +76 -0
  40. package/core/platform/map-utilities.js.map +1 -0
  41. package/core/platform/number-utilities.d.ts +15 -0
  42. package/core/platform/number-utilities.js +82 -0
  43. package/core/platform/number-utilities.js.map +1 -0
  44. package/core/platform/platform-tsconfig.json +59 -0
  45. package/core/platform/platform.d.ts +19 -0
  46. package/core/platform/platform.js +54 -0
  47. package/core/platform/platform.js.compressed +0 -0
  48. package/core/platform/platform.js.hash +1 -0
  49. package/core/platform/platform.js.map +1 -0
  50. package/core/platform/platform.prebundle.d.ts +15 -0
  51. package/core/platform/platform.prebundle.js +50 -0
  52. package/core/platform/platform.prebundle.js.map +1 -0
  53. package/core/platform/platform.prebundle.ts +64 -0
  54. package/core/platform/promise-utilities.d.ts +10 -0
  55. package/core/platform/promise-utilities.js +18 -0
  56. package/core/platform/promise-utilities.js.map +1 -0
  57. package/core/platform/set-utilities.d.ts +2 -0
  58. package/core/platform/set-utilities.js +23 -0
  59. package/core/platform/set-utilities.js.map +1 -0
  60. package/core/platform/string-utilities.d.ts +71 -0
  61. package/core/platform/string-utilities.js +513 -0
  62. package/core/platform/string-utilities.js.map +1 -0
  63. package/core/platform/typescript-utilities.d.ts +56 -0
  64. package/core/platform/typescript-utilities.js +25 -0
  65. package/core/platform/typescript-utilities.js.map +1 -0
  66. package/generated/protocol.d.ts +17923 -0
  67. package/generated/protocol.js +5 -0
  68. package/models/cpu_profile/CPUProfileDataModel.d.ts +77 -0
  69. package/models/cpu_profile/CPUProfileDataModel.js +508 -0
  70. package/models/cpu_profile/CPUProfileDataModel.js.map +1 -0
  71. package/models/cpu_profile/ProfileTreeModel.d.ts +29 -0
  72. package/models/cpu_profile/ProfileTreeModel.js +95 -0
  73. package/models/cpu_profile/ProfileTreeModel.js.map +1 -0
  74. package/models/cpu_profile/bundle-tsconfig.json +1 -0
  75. package/models/cpu_profile/cpu_profile-tsconfig.json +51 -0
  76. package/models/cpu_profile/cpu_profile.d.ts +3 -0
  77. package/models/cpu_profile/cpu_profile.js +7 -0
  78. package/models/cpu_profile/cpu_profile.js.map +1 -0
  79. package/models/cpu_profile/devtools_entrypoint-bundle-typescript-tsconfig.json +44 -0
  80. package/models/trace/EntriesFilter.d.ts +55 -0
  81. package/models/trace/EntriesFilter.js +243 -0
  82. package/models/trace/EntriesFilter.js.map +1 -0
  83. package/models/trace/LegacyTracingModel.d.ts +1 -0
  84. package/models/trace/LegacyTracingModel.js +1 -0
  85. package/models/trace/LegacyTracingModel.js.map +1 -0
  86. package/models/trace/ModelImpl.d.ts +110 -0
  87. package/models/trace/ModelImpl.js +175 -0
  88. package/models/trace/ModelImpl.js.map +1 -0
  89. package/models/trace/Processor.d.ts +36 -0
  90. package/models/trace/Processor.js +213 -0
  91. package/models/trace/Processor.js.map +1 -0
  92. package/models/trace/SDKServices.js +104 -0
  93. package/models/trace/SDKServices.js.map +7 -0
  94. package/models/trace/TraceProcessor.js +133 -0
  95. package/models/trace/TraceProcessor.js.map +7 -0
  96. package/models/trace/TracingManager.d.ts +1 -0
  97. package/models/trace/TracingManager.js +1 -0
  98. package/models/trace/TracingManager.js.map +1 -0
  99. package/models/trace/TreeManipulator.js +85 -0
  100. package/models/trace/TreeManipulator.js.map +7 -0
  101. package/models/trace/bundle-tsconfig.json +1 -0
  102. package/models/trace/devtools_entrypoint-bundle-typescript-tsconfig.json +44 -0
  103. package/models/trace/devtools_entrypoint-legacy-typescript-tsconfig.json +43 -0
  104. package/models/trace/extras/FetchNodes.d.ts +46 -0
  105. package/models/trace/extras/FetchNodes.js +145 -0
  106. package/models/trace/extras/FetchNodes.js.map +1 -0
  107. package/models/trace/extras/FilmStrip.d.ts +19 -0
  108. package/models/trace/extras/FilmStrip.js +44 -0
  109. package/models/trace/extras/FilmStrip.js.map +1 -0
  110. package/models/trace/extras/MainThreadActivity.d.ts +2 -0
  111. package/models/trace/extras/MainThreadActivity.js +77 -0
  112. package/models/trace/extras/MainThreadActivity.js.map +1 -0
  113. package/models/trace/extras/Metadata.d.ts +2 -0
  114. package/models/trace/extras/Metadata.js +44 -0
  115. package/models/trace/extras/Metadata.js.map +1 -0
  116. package/models/trace/extras/bundle-tsconfig.json +1 -0
  117. package/models/trace/extras/devtools_entrypoint-bundle-typescript-tsconfig.json +44 -0
  118. package/models/trace/extras/extras-tsconfig.json +59 -0
  119. package/models/trace/extras/extras.d.ts +1 -0
  120. package/models/trace/extras/extras.js +1 -0
  121. package/models/trace/extras/extras.js.map +1 -0
  122. package/models/trace/frames/TimelineFrameModel.js +392 -0
  123. package/models/trace/frames/TimelineFrameModel.js.map +7 -0
  124. package/models/trace/frames/bundle-tsconfig.json +1 -0
  125. package/models/trace/frames/devtools_entrypoint-bundle-typescript-tsconfig.json +43 -0
  126. package/models/trace/frames/frames-tsconfig.json +58 -0
  127. package/models/trace/frames/frames.js +5 -0
  128. package/models/trace/frames/frames.js.map +7 -0
  129. package/models/trace/handlers/AnimationHandler.d.ts +8 -0
  130. package/models/trace/handlers/AnimationHandler.js +32 -0
  131. package/models/trace/handlers/AnimationHandler.js.map +1 -0
  132. package/models/trace/handlers/AuctionWorkletsHandler.d.ts +8 -0
  133. package/models/trace/handlers/AuctionWorkletsHandler.js +160 -0
  134. package/models/trace/handlers/AuctionWorkletsHandler.js.map +1 -0
  135. package/models/trace/handlers/FramesHandler.d.ts +76 -0
  136. package/models/trace/handlers/FramesHandler.js +457 -0
  137. package/models/trace/handlers/FramesHandler.js.map +1 -0
  138. package/models/trace/handlers/GPUHandler.d.ts +11 -0
  139. package/models/trace/handlers/GPUHandler.js +54 -0
  140. package/models/trace/handlers/GPUHandler.js.map +1 -0
  141. package/models/trace/handlers/InitiatorsHandler.d.ts +10 -0
  142. package/models/trace/handlers/InitiatorsHandler.js +184 -0
  143. package/models/trace/handlers/InitiatorsHandler.js.map +1 -0
  144. package/models/trace/handlers/InvalidationsHandler.d.ts +10 -0
  145. package/models/trace/handlers/InvalidationsHandler.js +120 -0
  146. package/models/trace/handlers/InvalidationsHandler.js.map +1 -0
  147. package/models/trace/handlers/LargestImagePaintHandler.d.ts +5 -0
  148. package/models/trace/handlers/LargestImagePaintHandler.js +38 -0
  149. package/models/trace/handlers/LargestImagePaintHandler.js.map +1 -0
  150. package/models/trace/handlers/LargestTextPaintHandler.d.ts +5 -0
  151. package/models/trace/handlers/LargestTextPaintHandler.js +26 -0
  152. package/models/trace/handlers/LargestTextPaintHandler.js.map +1 -0
  153. package/models/trace/handlers/LayerTreeHandler.d.ts +13 -0
  154. package/models/trace/handlers/LayerTreeHandler.js +116 -0
  155. package/models/trace/handlers/LayerTreeHandler.js.map +1 -0
  156. package/models/trace/handlers/LayoutShiftsHandler.d.ts +44 -0
  157. package/models/trace/handlers/LayoutShiftsHandler.js +347 -0
  158. package/models/trace/handlers/LayoutShiftsHandler.js.map +1 -0
  159. package/models/trace/handlers/MemoryHandler.d.ts +7 -0
  160. package/models/trace/handlers/MemoryHandler.js +20 -0
  161. package/models/trace/handlers/MemoryHandler.js.map +1 -0
  162. package/models/trace/handlers/MetaHandler.d.ts +37 -0
  163. package/models/trace/handlers/MetaHandler.js +338 -0
  164. package/models/trace/handlers/MetaHandler.js.map +1 -0
  165. package/models/trace/handlers/Migration.js +27 -0
  166. package/models/trace/handlers/Migration.js.map +7 -0
  167. package/models/trace/handlers/ModelHandlers.d.ts +21 -0
  168. package/models/trace/handlers/ModelHandlers.js +25 -0
  169. package/models/trace/handlers/ModelHandlers.js.map +1 -0
  170. package/models/trace/handlers/NetworkRequestsHandler.d.ts +17 -0
  171. package/models/trace/handlers/NetworkRequestsHandler.js +361 -0
  172. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -0
  173. package/models/trace/handlers/PageLoadMetricsHandler.d.ts +67 -0
  174. package/models/trace/handlers/PageLoadMetricsHandler.js +407 -0
  175. package/models/trace/handlers/PageLoadMetricsHandler.js.map +1 -0
  176. package/models/trace/handlers/RendererHandler.d.ts +101 -0
  177. package/models/trace/handlers/RendererHandler.js +325 -0
  178. package/models/trace/handlers/RendererHandler.js.map +1 -0
  179. package/models/trace/handlers/SamplesHandler.d.ts +46 -0
  180. package/models/trace/handlers/SamplesHandler.js +215 -0
  181. package/models/trace/handlers/SamplesHandler.js.map +1 -0
  182. package/models/trace/handlers/ScreenshotsHandler.d.ts +7 -0
  183. package/models/trace/handlers/ScreenshotsHandler.js +79 -0
  184. package/models/trace/handlers/ScreenshotsHandler.js.map +1 -0
  185. package/models/trace/handlers/Threads.d.ts +33 -0
  186. package/models/trace/handlers/Threads.js +95 -0
  187. package/models/trace/handlers/Threads.js.map +1 -0
  188. package/models/trace/handlers/UberFramesHandler.js +293 -0
  189. package/models/trace/handlers/UberFramesHandler.js.map +7 -0
  190. package/models/trace/handlers/UserInteractionsHandler.d.ts +57 -0
  191. package/models/trace/handlers/UserInteractionsHandler.js +267 -0
  192. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -0
  193. package/models/trace/handlers/UserTimingsHandler.d.ts +28 -0
  194. package/models/trace/handlers/UserTimingsHandler.js +108 -0
  195. package/models/trace/handlers/UserTimingsHandler.js.map +1 -0
  196. package/models/trace/handlers/WarningsHandler.d.ts +14 -0
  197. package/models/trace/handlers/WarningsHandler.js +125 -0
  198. package/models/trace/handlers/WarningsHandler.js.map +1 -0
  199. package/models/trace/handlers/WorkersHandler.d.ts +11 -0
  200. package/models/trace/handlers/WorkersHandler.js +52 -0
  201. package/models/trace/handlers/WorkersHandler.js.map +1 -0
  202. package/models/trace/handlers/bundle-tsconfig.json +1 -0
  203. package/models/trace/handlers/devtools_entrypoint-bundle-typescript-tsconfig.json +44 -0
  204. package/models/trace/handlers/handlers-tsconfig.json +79 -0
  205. package/models/trace/handlers/handlers.d.ts +3 -0
  206. package/models/trace/handlers/handlers.js +7 -0
  207. package/models/trace/handlers/handlers.js.map +1 -0
  208. package/models/trace/handlers/types.d.ts +45 -0
  209. package/models/trace/handlers/types.js +18 -0
  210. package/models/trace/handlers/types.js.map +1 -0
  211. package/models/trace/helpers/SamplesIntegrator.d.ts +49 -0
  212. package/models/trace/helpers/SamplesIntegrator.js +397 -0
  213. package/models/trace/helpers/SamplesIntegrator.js.map +1 -0
  214. package/models/trace/helpers/Timing.d.ts +26 -0
  215. package/models/trace/helpers/Timing.js +162 -0
  216. package/models/trace/helpers/Timing.js.map +1 -0
  217. package/models/trace/helpers/Trace.d.ts +37 -0
  218. package/models/trace/helpers/Trace.js +230 -0
  219. package/models/trace/helpers/Trace.js.map +1 -0
  220. package/models/trace/helpers/TreeHelpers.d.ts +90 -0
  221. package/models/trace/helpers/TreeHelpers.js +222 -0
  222. package/models/trace/helpers/TreeHelpers.js.map +1 -0
  223. package/models/trace/helpers/bundle-tsconfig.json +1 -0
  224. package/models/trace/helpers/devtools_entrypoint-bundle-typescript-tsconfig.json +44 -0
  225. package/models/trace/helpers/helpers-tsconfig.json +59 -0
  226. package/models/trace/helpers/helpers.d.ts +4 -0
  227. package/models/trace/helpers/helpers.js +8 -0
  228. package/models/trace/helpers/helpers.js.map +1 -0
  229. package/models/trace/legacy-tsconfig.json +1 -0
  230. package/models/trace/root-causes/LayoutShift.d.ts +119 -0
  231. package/models/trace/root-causes/LayoutShift.js +517 -0
  232. package/models/trace/root-causes/LayoutShift.js.map +1 -0
  233. package/models/trace/root-causes/RootCauses.d.ts +14 -0
  234. package/models/trace/root-causes/RootCauses.js +11 -0
  235. package/models/trace/root-causes/RootCauses.js.map +1 -0
  236. package/models/trace/root-causes/bundle-tsconfig.json +1 -0
  237. package/models/trace/root-causes/devtools_entrypoint-bundle-typescript-tsconfig.json +44 -0
  238. package/models/trace/root-causes/root-causes-tsconfig.json +57 -0
  239. package/models/trace/root-causes/root-causes.d.ts +1 -0
  240. package/models/trace/root-causes/root-causes.js +5 -0
  241. package/models/trace/root-causes/root-causes.js.map +1 -0
  242. package/models/trace/sdk_services/DOMNodeLookup.js +41 -0
  243. package/models/trace/sdk_services/DOMNodeLookup.js.map +7 -0
  244. package/models/trace/sdk_services/LayoutShifts.js +68 -0
  245. package/models/trace/sdk_services/LayoutShifts.js.map +7 -0
  246. package/models/trace/sdk_services/bundle-tsconfig.json +1 -0
  247. package/models/trace/sdk_services/devtools_entrypoint-bundle-typescript-tsconfig.json +41 -0
  248. package/models/trace/sdk_services/sdk_services-tsconfig.json +57 -0
  249. package/models/trace/sdk_services/sdk_services.js +7 -0
  250. package/models/trace/sdk_services/sdk_services.js.map +7 -0
  251. package/models/trace/trace-legacy.js +16 -0
  252. package/models/trace/trace-legacy.js.map +7 -0
  253. package/models/trace/trace-tsconfig.json +69 -0
  254. package/models/trace/trace.d.ts +11 -0
  255. package/models/trace/trace.js +17 -0
  256. package/models/trace/trace.js.map +1 -0
  257. package/models/trace/types/Configuration.d.ts +33 -0
  258. package/models/trace/types/Configuration.js +29 -0
  259. package/models/trace/types/Configuration.js.map +1 -0
  260. package/models/trace/types/File.d.ts +23 -0
  261. package/models/trace/types/File.js +5 -0
  262. package/models/trace/types/File.js.map +1 -0
  263. package/models/trace/types/Timing.d.ts +25 -0
  264. package/models/trace/types/Timing.js +16 -0
  265. package/models/trace/types/Timing.js.map +1 -0
  266. package/models/trace/types/TraceEvents.d.ts +1571 -0
  267. package/models/trace/types/TraceEvents.js +388 -0
  268. package/models/trace/types/TraceEvents.js.map +1 -0
  269. package/models/trace/types/bundle-tsconfig.json +1 -0
  270. package/models/trace/types/devtools_entrypoint-bundle-typescript-tsconfig.json +44 -0
  271. package/models/trace/types/types-tsconfig.json +47 -0
  272. package/models/trace/types/types.d.ts +4 -0
  273. package/models/trace/types/types.js +8 -0
  274. package/models/trace/types/types.js.map +1 -0
  275. package/models/trace/worker/Processor.js +143 -0
  276. package/models/trace/worker/Processor.js.map +7 -0
  277. package/models/trace/worker/Types.js +1 -0
  278. package/models/trace/worker/Types.js.map +7 -0
  279. package/models/trace/worker/bundle-tsconfig.json +1 -0
  280. package/models/trace/worker/devtools_entrypoint-bundle-typescript-tsconfig.json +41 -0
  281. package/models/trace/worker/devtools_entrypoint-worker_entrypoint-typescript-tsconfig.json +41 -0
  282. package/models/trace/worker/processor-tsconfig.json +45 -0
  283. package/models/trace/worker/worker.js +7 -0
  284. package/models/trace/worker/worker.js.map +7 -0
  285. package/models/trace/worker/worker_entrypoint-tsconfig.json +1 -0
  286. package/models/trace/worker/worker_entrypoint.js +36 -0
  287. package/models/trace/worker/worker_entrypoint.js.map +7 -0
  288. package/package.json +2 -2
  289. package/TracingManager.js +0 -0
  290. package/extras/extras.js +0 -0
  291. package/trace.mjs +0 -6980
  292. package/trace.mjs.map +0 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CPUProfileDataModel.js","sourceRoot":"","sources":["../../../../../../front_end/models/cpu_profile/CPUProfileDataModel.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,QAAQ,MAAM,iCAAiC,CAAC;AAG5D,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AAEpE,MAAM,OAAO,cAAe,SAAQ,WAAW;IACpC,EAAE,CAAS;IACX,IAAI,CAAS;IACtB,gEAAgE;IAChE,kEAAkE;IAClE,qEAAqE;IACrE,+DAA+D;IAC/D,yBAAyB;IACzB,aAAa,CAAiD;IACrD,WAAW,CAAc;IAElC,YAAY,IAAmC,EAAE,gBAAwB,CAAC,kBAAkB;QAC1F,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAK;YACjB,mEAAmE;YACnE,mBAAmB;YACnB,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC;YAClC,mEAAmE;YACnE,mBAAmB;YACnB,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC;YAC1B,mEAAmE;YACnE,mBAAmB;YACnB,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC;YAChB,mEAAmE;YACnE,mBAAmB;YACnB,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC;YAClC,mE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AAI,QAAQ,CAAC;YAChD,kBAAkB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC;YAClG,EAAE,QAAQ,CAAC;SACZ;IACH,CAAC;IACD;;OAEG;IACH,WAAW,CAAC,KAAa;QACvB,OAAO,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC;IAC/E,CAAC;IACD;;OAEG;IACH,QAAQ,CAAC,MAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC;IAClD,CAAC;IAED,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACzB,OAAO,IAAI,CAAC;SACb;QACD,OAAO,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF","sourcesContent":["// Copyright 2014 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as Platform from '../../core/platform/platform.js';\nimport type * as Protocol from '../../generated/protocol.js';\n\nimport {ProfileNode, ProfileTreeModel} from './ProfileTreeModel.js';\n\nexport class CPUProfileNode extends ProfileNode {\n override id: number;\n override self: number;\n // Position ticks are available in profile nodes coming from CDP\n // profiles and not in those coming from tracing. They are used to\n // calculate the line level execution time shown in the Sources panel\n // after recording a profile. For trace CPU profiles we use the\n // `lines` array instead.\n positionTicks: Protocol.Profiler.PositionTickInfo[]|undefined;\n override deoptReason: string|null;\n\n constructor(node: Protocol.Profiler.ProfileNode, samplingInterval: number /* milliseconds */) {\n const callFrame = node.callFrame || ({\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n functionName: node['functionName'],\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n scriptId: node['scriptId'],\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n url: node['url'],\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n lineNumber: node['lineNumber'] - 1,\n // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration\n // @ts-expect-error\n columnNumber: node['columnNumber'] - 1,\n } as Protocol.Runtime.CallFrame);\n super(callFrame);\n this.id = node.id;\n this.self = (node.hitCount || 0) * samplingInterval;\n this.positionTicks = node.positionTicks;\n // Compatibility: legacy backends could provide \"no reason\" for optimized functions.\n this.deoptReason = node.deoptReason && node.deoptReason !== 'no reason' ? node.deoptReason : null;\n }\n}\n\nexport class CPUProfileDataModel extends ProfileTreeModel {\n profileStartTime: number /* milliseconds */;\n profileEndTime: number /* milliseconds */;\n timestamps: number[];\n samples: number[]|undefined;\n lines?: number[];\n totalHitCount: number;\n profileHead: CPUProfileNode;\n /**\n * A cache for the nodes we have parsed.\n * Note: \"Parsed\" nodes are different from the \"Protocol\" nodes, the\n * latter being the raw data we receive from the backend.\n */\n #idToParsedNode!: Map<number, ProfileNode>;\n gcNode?: ProfileNode;\n programNode?: ProfileNode;\n idleNode?: ProfileNode;\n #stackStartTimes?: number[];\n #stackChildrenDuration?: number[];\n constructor(profile: ExtendedProfile) {\n super();\n // @ts-ignore Legacy types\n const isLegacyFormat = Boolean(profile['head']);\n if (isLegacyFormat) {\n // Legacy format contains raw timestamps and start/stop times are in seconds.\n this.profileStartTime = profile.startTime * 1000;\n this.profileEndTime = profile.endTime * 1000;\n // @ts-ignore Legacy types\n this.timestamps = profile.timestamps;\n this.compatibilityConversionHeadToNodes(profile);\n } else {\n // Current format encodes timestamps as deltas. Start/stop times are in microseconds.\n this.profileStartTime = profile.startTime / 1000;\n this.profileEndTime = profile.endTime / 1000;\n this.timestamps = this.convertTimeDeltas(profile);\n }\n this.samples = profile.samples;\n\n // Lines are available only in profiles coming from tracing.\n // Elements in the lines array have a 1 to 1 correspondance with\n // samples, by array position. They can be 1 or 0 and indicate if\n // there is line data for a given sample, i.e. if a given sample\n // needs to be included to calculate the line level execution time\n // data, which we show in the sources panel after recording a\n // profile.\n this.lines = profile.lines;\n this.totalHitCount = 0;\n this.profileHead = this.translateProfileTree(profile.nodes);\n this.initialize(this.profileHead);\n this.extractMetaNodes();\n if (this.samples?.length) {\n this.sortSamples();\n this.normalizeTimestamps();\n this.fixMissingSamples();\n }\n }\n\n private compatibilityConversionHeadToNodes(profile: Protocol.Profiler.Profile): void {\n // @ts-ignore Legacy types\n if (!profile.head || profile.nodes) {\n return;\n }\n const nodes: Protocol.Profiler.ProfileNode[] = [];\n // @ts-ignore Legacy types\n convertNodesTree(profile.head);\n profile.nodes = nodes;\n // @ts-ignore Legacy types\n delete profile.head;\n function convertNodesTree(node: Protocol.Profiler.ProfileNode): number {\n nodes.push(node);\n // @ts-ignore Legacy types\n node.children = (node.children as Protocol.Profiler.ProfileNode[]).map(convertNodesTree);\n return node.id;\n }\n }\n\n /**\n * Calculate timestamps using timeDeltas. Some CPU profile formats,\n * like the ones contained in traces have timeDeltas instead of\n * timestamps.\n */\n private convertTimeDeltas(profile: Protocol.Profiler.Profile): number[] {\n if (!profile.timeDeltas) {\n return [];\n }\n let lastTimeMicroSec = profile.startTime;\n const timestamps = new Array(profile.timeDeltas.length);\n for (let i = 0; i < profile.timeDeltas.length; ++i) {\n lastTimeMicroSec += profile.timeDeltas[i];\n timestamps[i] = lastTimeMicroSec;\n }\n return timestamps;\n }\n\n /**\n * Creates a Tree of CPUProfileNodes using the Protocol.Profiler.ProfileNodes.\n * As the tree is built, samples of native code (prefixed with \"native \") are\n * filtered out. Samples of filtered nodes are replaced with the parent of the\n * node being filtered.\n *\n * This function supports legacy and new definitions of the CDP Profiler.Profile\n * type.\n */\n private translateProfileTree(nodes: Protocol.Profiler.ProfileNode[]): CPUProfileNode {\n function buildChildrenFromParents(nodes: Protocol.Profiler.ProfileNode[]): void {\n if (nodes[0].children) {\n return;\n }\n nodes[0].children = [];\n for (let i = 1; i < nodes.length; ++i) {\n const node = nodes[i];\n // @ts-ignore Legacy types\n const parentNode = protocolNodeById.get(node.parent);\n // @ts-ignore Legacy types\n if (parentNode.children) {\n // @ts-ignore Legacy types\n parentNode.children.push(node.id);\n } else {\n // @ts-ignore Legacy types\n parentNode.children = [node.id];\n }\n }\n }\n\n /**\n * Calculate how many times each node was sampled in the profile, if\n * not available in the profile data.\n */\n function buildHitCountFromSamples(nodes: Protocol.Profiler.ProfileNode[], samples: number[]|undefined): void {\n // If hit count is available, this profile has the new format, so\n // no need to continue.`\n if (typeof (nodes[0].hitCount) === 'number') {\n return;\n }\n if (!samples) {\n throw new Error('Error: Neither hitCount nor samples are present in profile.');\n }\n for (let i = 0; i < nodes.length; ++i) {\n nodes[i].hitCount = 0;\n }\n for (let i = 0; i < samples.length; ++i) {\n const node = protocolNodeById.get(samples[i]);\n if (!node || node.hitCount === undefined) {\n continue;\n }\n node.hitCount++;\n }\n }\n\n // A cache for the raw nodes received from the traces / CDP.\n const protocolNodeById = new Map<number, Protocol.Profiler.ProfileNode>();\n for (let i = 0; i < nodes.length; ++i) {\n const node = nodes[i];\n protocolNodeById.set(node.id, node);\n }\n\n buildHitCountFromSamples(nodes, this.samples);\n buildChildrenFromParents(nodes);\n this.totalHitCount = nodes.reduce((acc, node) => acc + (node.hitCount || 0), 0);\n const sampleTime = (this.profileEndTime - this.profileStartTime) / this.totalHitCount;\n const root = nodes[0];\n // If a node is filtered out, its samples are replaced with its parent,\n // so we keep track of the which id to use in the samples data.\n const idToUseForRemovedNode = new Map<number, number>([[root.id, root.id]]);\n this.#idToParsedNode = new Map();\n\n const resultRoot = new CPUProfileNode(root, sampleTime);\n this.#idToParsedNode.set(root.id, resultRoot);\n if (!root.children) {\n throw new Error('Missing children for root');\n }\n const parentNodeStack = root.children.map(() => resultRoot);\n const sourceNodeStack = root.children.map(id => protocolNodeById.get(id));\n while (sourceNodeStack.length) {\n let parentNode = parentNodeStack.pop();\n const sourceNode = sourceNodeStack.pop();\n if (!sourceNode || !parentNode) {\n continue;\n }\n if (!sourceNode.children) {\n sourceNode.children = [];\n }\n const targetNode = new CPUProfileNode(sourceNode, sampleTime);\n parentNode.children.push(targetNode);\n parentNode = targetNode;\n\n idToUseForRemovedNode.set(sourceNode.id, parentNode.id);\n parentNodeStack.push.apply(parentNodeStack, sourceNode.children.map(() => parentNode as CPUProfileNode));\n sourceNodeStack.push.apply(sourceNodeStack, sourceNode.children.map(id => protocolNodeById.get(id)));\n this.#idToParsedNode.set(sourceNode.id, targetNode);\n }\n if (this.samples) {\n this.samples = this.samples.map(id => idToUseForRemovedNode.get(id) as number);\n }\n return resultRoot;\n }\n\n /**\n * Sorts the samples array using the timestamps array (there is a one\n * to one matching by index between the two).\n */\n private sortSamples(): void {\n if (!this.timestamps || !this.samples) {\n return;\n }\n\n const timestamps = this.timestamps;\n const samples = this.samples;\n const orderedIndices = timestamps.map((_x, index) => index);\n orderedIndices.sort((a, b) => timestamps[a] - timestamps[b]);\n\n this.timestamps = [];\n this.samples = [];\n\n for (let i = 0; i < orderedIndices.length; i++) {\n const orderedIndex = orderedIndices[i];\n this.timestamps.push(timestamps[orderedIndex]);\n this.samples.push(samples[orderedIndex]);\n }\n }\n\n /**\n * Fills in timestamps and/or time deltas from legacy profiles where\n * they could be missing.\n */\n private normalizeTimestamps(): void {\n if (!this.samples) {\n return;\n }\n let timestamps: number[] = this.timestamps;\n if (!timestamps) {\n // Support loading CPU profiles that are missing timestamps and\n // timedeltas\n const profileStartTime = this.profileStartTime;\n const interval = (this.profileEndTime - profileStartTime) / this.samples.length;\n // Add an extra timestamp used to calculate the last sample duration.\n timestamps = new Array(this.samples.length + 1);\n for (let i = 0; i < timestamps.length; ++i) {\n timestamps[i] = profileStartTime + i * interval;\n }\n this.timestamps = timestamps;\n return;\n }\n\n // Convert samples from micro to milliseconds\n for (let i = 0; i < timestamps.length; ++i) {\n timestamps[i] /= 1000;\n }\n if (this.samples.length === timestamps.length) {\n // Add an extra timestamp used to calculate the last sample duration.\n const lastTimestamp = timestamps.at(-1) || 0;\n const averageIntervalTime = (lastTimestamp - timestamps[0]) / (timestamps.length - 1);\n this.timestamps.push(lastTimestamp + averageIntervalTime);\n }\n this.profileStartTime = timestamps.at(0) || this.profileStartTime;\n this.profileEndTime = timestamps.at(-1) || this.profileEndTime;\n }\n\n /**\n * Some nodes do not refer to JS samples but to V8 system tasks, AKA\n * \"meta\" nodes. This function extracts those nodes from the profile.\n */\n private extractMetaNodes(): void {\n const topLevelNodes = this.profileHead.children;\n for (let i = 0; i < topLevelNodes.length && !(this.gcNode && this.programNode && this.idleNode); i++) {\n const node = topLevelNodes[i];\n if (node.functionName === '(garbage collector)') {\n this.gcNode = node;\n } else if (node.functionName === '(program)') {\n this.programNode = node;\n } else if (node.functionName === '(idle)') {\n this.idleNode = node;\n }\n }\n }\n\n private fixMissingSamples(): void {\n // Sometimes the V8 sampler is not able to parse the JS stack and returns\n // a (program) sample instead. The issue leads to call frames being split\n // apart when they shouldn't.\n // Here's a workaround for that. When there's a single (program) sample\n // between two call stacks sharing the same bottom node, it is replaced\n // with the preceeding sample.\n const samples = this.samples;\n if (!samples) {\n return;\n }\n const samplesCount = samples.length;\n if (!this.programNode || samplesCount < 3) {\n return;\n }\n const idToNode = this.#idToParsedNode;\n const programNodeId = this.programNode.id;\n const gcNodeId = this.gcNode ? this.gcNode.id : -1;\n const idleNodeId = this.idleNode ? this.idleNode.id : -1;\n let prevNodeId: number = samples[0];\n let nodeId: number = samples[1];\n for (let sampleIndex = 1; sampleIndex < samplesCount - 1; sampleIndex++) {\n const nextNodeId = samples[sampleIndex + 1];\n const prevNode = idToNode.get(prevNodeId);\n const nextNode = idToNode.get(nextNodeId);\n if (prevNodeId === undefined || nextNodeId === undefined || !prevNode || !nextNode) {\n console.error(`Unexpectedly found undefined nodes: ${prevNodeId} ${nextNodeId}`);\n continue;\n }\n if (nodeId === programNodeId && !isSystemNode(prevNodeId) && !isSystemNode(nextNodeId) &&\n bottomNode(prevNode) === bottomNode(nextNode)) {\n samples[sampleIndex] = prevNodeId;\n }\n prevNodeId = nodeId;\n nodeId = nextNodeId;\n }\n function bottomNode(node: ProfileNode): ProfileNode {\n while (node.parent && node.parent.parent) {\n node = node.parent;\n }\n return node;\n }\n function isSystemNode(nodeId: number): boolean {\n return nodeId === programNodeId || nodeId === gcNodeId || nodeId === idleNodeId;\n }\n }\n\n /**\n * Traverses the call tree derived from the samples calling back when a call is opened\n * and when it's closed\n */\n forEachFrame(\n openFrameCallback: (depth: number, node: ProfileNode, timestamp: number) => void,\n closeFrameCallback: (depth: number, node: ProfileNode, timestamp: number, dur: number, selfTime: number) => void,\n startTime?: number, stopTime?: number): void {\n if (!this.profileHead || !this.samples) {\n return;\n }\n\n startTime = startTime || 0;\n stopTime = stopTime || Infinity;\n const samples = this.samples;\n const timestamps = this.timestamps;\n const idToNode = this.#idToParsedNode;\n const gcNode = this.gcNode;\n const samplesCount = samples.length;\n const startIndex =\n Platform.ArrayUtilities.lowerBound(timestamps, startTime, Platform.ArrayUtilities.DEFAULT_COMPARATOR);\n let stackTop = 0;\n const stackNodes: ProfileNode[] = [];\n let prevId: number = this.profileHead.id;\n let sampleTime;\n let gcParentNode: ProfileNode|null = null;\n\n // Extra slots for gc being put on top,\n // and one at the bottom to allow safe stackTop-1 access.\n const stackDepth = this.maxDepth + 3;\n if (!this.#stackStartTimes) {\n this.#stackStartTimes = new Array(stackDepth);\n }\n const stackStartTimes = this.#stackStartTimes;\n if (!this.#stackChildrenDuration) {\n this.#stackChildrenDuration = new Array(stackDepth);\n }\n const stackChildrenDuration = this.#stackChildrenDuration;\n\n let node;\n let sampleIndex;\n for (sampleIndex = startIndex; sampleIndex < samplesCount; sampleIndex++) {\n sampleTime = timestamps[sampleIndex];\n if (sampleTime >= stopTime) {\n break;\n }\n const id = samples[sampleIndex];\n if (id === prevId) {\n continue;\n }\n node = idToNode.get(id);\n let prevNode: ProfileNode|null = idToNode.get(prevId) || null;\n if (!prevNode) {\n continue;\n }\n\n if (gcNode && node === gcNode) {\n // GC samples have no stack, so we just put GC node on top of the last recorded sample.\n gcParentNode = prevNode;\n openFrameCallback(gcParentNode.depth + 1, gcNode, sampleTime);\n stackStartTimes[++stackTop] = sampleTime;\n stackChildrenDuration[stackTop] = 0;\n prevId = id;\n continue;\n }\n if (gcNode && prevNode === gcNode && gcParentNode) {\n // end of GC frame\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(gcParentNode.depth + 1, gcNode, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n prevNode = gcParentNode;\n prevId = prevNode.id;\n gcParentNode = null;\n }\n\n // If the depth of this node is greater than the depth of the\n // previous one, new calls happened in between and we need to open\n // them, so track all of them in stackNodes.\n while (node && node.depth > prevNode.depth) {\n stackNodes.push(node);\n node = node.parent;\n }\n\n // If `prevNode` differs from `node`, the current sample was taken\n // after a change in the call stack, meaning that frames in the\n // path of `prevNode` that differ from those in the path of `node`\n // can be closed. So go down to the lowest common ancestor and\n // close current intervals.\n //\n // For example:\n //\n // prevNode node\n // | |\n // v v\n // [---D--]\n // [---C--][--E--]\n // [------B------] <- LCA\n // [------A------]\n //\n // Because a sample was taken with A, B and E in the stack, it\n // means C and D finished and we can close them.\n while (prevNode && prevNode !== node) {\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(prevNode.depth, prevNode, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n // Track calls to open after previous calls were closed\n // In the example above, this would add E to the tracking stack.\n if (node && node.depth === prevNode.depth) {\n stackNodes.push(node);\n node = node.parent;\n }\n prevNode = prevNode.parent;\n }\n\n // Go up the nodes stack and open new intervals.\n while (stackNodes.length) {\n const currentNode = stackNodes.pop();\n if (!currentNode) {\n break;\n }\n node = currentNode;\n openFrameCallback(currentNode.depth, currentNode, sampleTime);\n stackStartTimes[++stackTop] = sampleTime;\n stackChildrenDuration[stackTop] = 0;\n }\n\n prevId = id;\n }\n\n // Close remaining intervals.\n sampleTime = timestamps[sampleIndex] || this.profileEndTime;\n if (node && gcParentNode && idToNode.get(prevId) === gcNode) {\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(gcParentNode.depth + 1, node, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n prevId = gcParentNode.id;\n }\n for (let node = idToNode.get(prevId); node && node.parent; node = node.parent) {\n const start = stackStartTimes[stackTop];\n const duration = sampleTime - start;\n stackChildrenDuration[stackTop - 1] += duration;\n closeFrameCallback(node.depth, node, start, duration, duration - stackChildrenDuration[stackTop]);\n --stackTop;\n }\n }\n /**\n * Returns the node that corresponds to a given index of a sample.\n */\n nodeByIndex(index: number): ProfileNode|null {\n return this.samples && this.#idToParsedNode.get(this.samples[index]) || null;\n }\n /**\n * Returns the node that corresponds to a given node id.\n */\n nodeById(nodeId: number): ProfileNode|null {\n return this.#idToParsedNode.get(nodeId) || null;\n }\n\n nodes(): ProfileNode[]|null {\n if (!this.#idToParsedNode) {\n return null;\n }\n return [...this.#idToParsedNode.values()];\n }\n}\n\n// Format used by profiles coming from traces.\nexport type ExtendedProfileNode = Protocol.Profiler.ProfileNode&{parent?: number};\nexport type ExtendedProfile =\n Protocol.Profiler.Profile&{nodes: Protocol.Profiler.ProfileNode[] | ExtendedProfileNode[], lines?: number[]};\n"]}
@@ -0,0 +1,29 @@
1
+ import type * as Protocol from '../../generated/protocol.js';
2
+ import type * as Platform from '../../core/platform/platform.js';
3
+ export declare class ProfileNode {
4
+ callFrame: Protocol.Runtime.CallFrame;
5
+ callUID: string;
6
+ self: number;
7
+ total: number;
8
+ id: number;
9
+ parent: ProfileNode | null;
10
+ children: ProfileNode[];
11
+ functionName: string;
12
+ depth: number;
13
+ deoptReason: string | null;
14
+ constructor(callFrame: Protocol.Runtime.CallFrame);
15
+ get scriptId(): Protocol.Runtime.ScriptId;
16
+ get url(): Platform.DevToolsPath.UrlString;
17
+ get lineNumber(): number;
18
+ get columnNumber(): number;
19
+ setFunctionName(name: string | null): void;
20
+ }
21
+ export declare class ProfileTreeModel {
22
+ root: ProfileNode;
23
+ total: number;
24
+ maxDepth: number;
25
+ constructor();
26
+ initialize(root: ProfileNode): void;
27
+ private assignDepthsAndParents;
28
+ private calculateTotals;
29
+ }
@@ -0,0 +1,95 @@
1
+ // Copyright 2016 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+ export class ProfileNode {
5
+ callFrame;
6
+ callUID;
7
+ self;
8
+ total;
9
+ id;
10
+ parent;
11
+ children;
12
+ functionName;
13
+ depth;
14
+ deoptReason;
15
+ constructor(callFrame) {
16
+ this.callFrame = callFrame;
17
+ this.callUID = `${callFrame.functionName}@${callFrame.scriptId}:${callFrame.lineNumber}:${callFrame.columnNumber}`;
18
+ this.self = 0;
19
+ this.total = 0;
20
+ this.id = 0;
21
+ this.functionName = callFrame.functionName;
22
+ this.parent = null;
23
+ this.children = [];
24
+ }
25
+ get scriptId() {
26
+ return String(this.callFrame.scriptId);
27
+ }
28
+ get url() {
29
+ return this.callFrame.url;
30
+ }
31
+ get lineNumber() {
32
+ return this.callFrame.lineNumber;
33
+ }
34
+ get columnNumber() {
35
+ return this.callFrame.columnNumber;
36
+ }
37
+ setFunctionName(name) {
38
+ if (name === null) {
39
+ return;
40
+ }
41
+ this.functionName = name;
42
+ }
43
+ }
44
+ export class ProfileTreeModel {
45
+ root;
46
+ total;
47
+ maxDepth;
48
+ constructor() {
49
+ }
50
+ initialize(root) {
51
+ this.root = root;
52
+ this.assignDepthsAndParents();
53
+ this.total = this.calculateTotals(this.root);
54
+ }
55
+ assignDepthsAndParents() {
56
+ const root = this.root;
57
+ // TODO(crbug.com/1354548): start depth from 0 once profiler
58
+ // panel dependencies are gone.
59
+ root.depth = -1;
60
+ root.parent = null;
61
+ this.maxDepth = 0;
62
+ const nodesToTraverse = [root];
63
+ while (nodesToTraverse.length) {
64
+ const parent = nodesToTraverse.pop();
65
+ const depth = parent.depth + 1;
66
+ if (depth > this.maxDepth) {
67
+ this.maxDepth = depth;
68
+ }
69
+ const children = parent.children;
70
+ for (const child of children) {
71
+ child.depth = depth;
72
+ child.parent = parent;
73
+ nodesToTraverse.push(child);
74
+ }
75
+ }
76
+ }
77
+ calculateTotals(root) {
78
+ const nodesToTraverse = [root];
79
+ const dfsList = [];
80
+ while (nodesToTraverse.length) {
81
+ const node = nodesToTraverse.pop();
82
+ node.total = node.self;
83
+ dfsList.push(node);
84
+ nodesToTraverse.push(...node.children);
85
+ }
86
+ while (dfsList.length > 1) {
87
+ const node = dfsList.pop();
88
+ if (node.parent) {
89
+ node.parent.total += node.total;
90
+ }
91
+ }
92
+ return root.total;
93
+ }
94
+ }
95
+ //# sourceMappingURL=ProfileTreeModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProfileTreeModel.js","sourceRoot":"","sources":["../../../../../../front_end/models/cpu_profile/ProfileTreeModel.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAK7B,MAAM,OAAO,WAAW;IACtB,SAAS,CAA6B;IACtC,OAAO,CAAS;IAChB,IAAI,CAAS;IACb,KAAK,CAAS;IACd,EAAE,CAAS;IACX,MAAM,CAAmB;IACzB,QAAQ,CAAgB;IACxB,YAAY,CAAS;IACrB,KAAK,CAAU;IACf,WAAW,CAAe;IAC1B,YAAY,SAAqC;QAC/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,GAAG,SAAS,CAAC,YAAY,IAAI,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,YAAY,EAAE,CAAC;QACnH,IAAI,CA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cesContent":["// Copyright 2016 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport type * as Protocol from '../../generated/protocol.js';\nimport type * as Platform from '../../core/platform/platform.js';\n\nexport class ProfileNode {\n callFrame: Protocol.Runtime.CallFrame;\n callUID: string;\n self: number;\n total: number;\n id: number;\n parent: ProfileNode|null;\n children: ProfileNode[];\n functionName: string;\n depth!: number;\n deoptReason!: string|null;\n constructor(callFrame: Protocol.Runtime.CallFrame) {\n this.callFrame = callFrame;\n this.callUID = `${callFrame.functionName}@${callFrame.scriptId}:${callFrame.lineNumber}:${callFrame.columnNumber}`;\n this.self = 0;\n this.total = 0;\n this.id = 0;\n this.functionName = callFrame.functionName;\n this.parent = null;\n this.children = [];\n }\n\n get scriptId(): Protocol.Runtime.ScriptId {\n return String(this.callFrame.scriptId) as Protocol.Runtime.ScriptId;\n }\n\n get url(): Platform.DevToolsPath.UrlString {\n return this.callFrame.url as Platform.DevToolsPath.UrlString;\n }\n\n get lineNumber(): number {\n return this.callFrame.lineNumber;\n }\n\n get columnNumber(): number {\n return this.callFrame.columnNumber;\n }\n\n setFunctionName(name: string|null): void {\n if (name === null) {\n return;\n }\n this.functionName = name;\n }\n}\n\nexport class ProfileTreeModel {\n root!: ProfileNode;\n total!: number;\n maxDepth!: number;\n constructor() {\n }\n\n initialize(root: ProfileNode): void {\n this.root = root;\n this.assignDepthsAndParents();\n this.total = this.calculateTotals(this.root);\n }\n\n private assignDepthsAndParents(): void {\n const root = this.root;\n // TODO(crbug.com/1354548): start depth from 0 once profiler\n // panel dependencies are gone.\n root.depth = -1;\n root.parent = null;\n this.maxDepth = 0;\n const nodesToTraverse = [root];\n while (nodesToTraverse.length) {\n const parent = (nodesToTraverse.pop() as ProfileNode);\n const depth = parent.depth + 1;\n if (depth > this.maxDepth) {\n this.maxDepth = depth;\n }\n const children = parent.children;\n for (const child of children) {\n child.depth = depth;\n child.parent = parent;\n nodesToTraverse.push(child);\n }\n }\n }\n\n private calculateTotals(root: ProfileNode): number {\n const nodesToTraverse = [root];\n const dfsList = [];\n while (nodesToTraverse.length) {\n const node = (nodesToTraverse.pop() as ProfileNode);\n node.total = node.self;\n dfsList.push(node);\n nodesToTraverse.push(...node.children);\n }\n while (dfsList.length > 1) {\n const node = (dfsList.pop() as ProfileNode);\n if (node.parent) {\n node.parent.total += node.total;\n }\n }\n return root.total;\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"compilerOptions":{"composite":true,"outDir":".","baseUrl":".","rootDir":"../../../../../../front_end/models/cpu_profile"},"files":["../../../../../../front_end/models/cpu_profile/cpu_profile.ts"],"references":[{"path":"./cpu_profile-tsconfig.json"}]}
@@ -0,0 +1,51 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "checkJs": true,
5
+ "composite": true,
6
+ "declaration": true,
7
+ "experimentalDecorators": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "inlineSources": true,
10
+ "lib": [
11
+ "esnext",
12
+ "dom",
13
+ "dom.iterable"
14
+ ],
15
+ "module": "esnext",
16
+ "noEmitOnError": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "noImplicitOverride": true,
19
+ "noImplicitReturns": true,
20
+ "noUnusedLocals": false,
21
+ "outDir": ".",
22
+ "rootDir": "../../../../../../front_end/models/cpu_profile",
23
+ "skipLibCheck": true,
24
+ "sourceMap": true,
25
+ "strict": true,
26
+ "target": "esnext",
27
+ "tsBuildInfoFile": "cpu_profile-tsconfig.json.tsbuildinfo",
28
+ "typeRoots": [],
29
+ "useUnknownInCatchVariables": false
30
+ },
31
+ "files": [
32
+ "../../../../../../front_end/models/cpu_profile/CPUProfileDataModel.ts",
33
+ "../../../../../../front_end/models/cpu_profile/ProfileTreeModel.ts",
34
+ "../../../../../../front_end/legacy/legacy-defs.d.ts",
35
+ "../../../../../../front_end/global_typings/global_defs.d.ts",
36
+ "../../../../../../front_end/global_typings/request_idle_callback.d.ts",
37
+ "../../../../../../node_modules/@types/filesystem/index.d.ts",
38
+ "../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
39
+ ],
40
+ "references": [
41
+ {
42
+ "path": "../../core/common/bundle-tsconfig.json"
43
+ },
44
+ {
45
+ "path": "../../core/platform/bundle-tsconfig.json"
46
+ },
47
+ {
48
+ "path": "../../generated/generated-tsconfig.json"
49
+ }
50
+ ]
51
+ }
@@ -0,0 +1,3 @@
1
+ import * as CPUProfileDataModel from './CPUProfileDataModel.js';
2
+ import * as ProfileTreeModel from './ProfileTreeModel.js';
3
+ export { CPUProfileDataModel, ProfileTreeModel, };
@@ -0,0 +1,7 @@
1
+ // Copyright 2023 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+ import * as CPUProfileDataModel from './CPUProfileDataModel.js';
5
+ import * as ProfileTreeModel from './ProfileTreeModel.js';
6
+ export { CPUProfileDataModel, ProfileTreeModel, };
7
+ //# sourceMappingURL=cpu_profile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cpu_profile.js","sourceRoot":"","sources":["../../../../../../front_end/models/cpu_profile/cpu_profile.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,gBAAgB,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GACjB,CAAC","sourcesContent":["// Copyright 2023 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as CPUProfileDataModel from './CPUProfileDataModel.js';\nimport * as ProfileTreeModel from './ProfileTreeModel.js';\n\nexport {\n CPUProfileDataModel,\n ProfileTreeModel,\n};\n"]}
@@ -0,0 +1,44 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "checkJs": true,
5
+ "composite": true,
6
+ "declaration": true,
7
+ "experimentalDecorators": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "inlineSources": true,
10
+ "lib": [
11
+ "esnext",
12
+ "dom",
13
+ "dom.iterable"
14
+ ],
15
+ "module": "esnext",
16
+ "noEmitOnError": true,
17
+ "noFallthroughCasesInSwitch": true,
18
+ "noImplicitOverride": true,
19
+ "noImplicitReturns": true,
20
+ "noUnusedLocals": false,
21
+ "outDir": ".",
22
+ "rootDir": "../../../../../../front_end/models/cpu_profile",
23
+ "skipLibCheck": true,
24
+ "sourceMap": true,
25
+ "strict": true,
26
+ "target": "esnext",
27
+ "tsBuildInfoFile": "devtools_entrypoint-bundle-typescript-tsconfig.json.tsbuildinfo",
28
+ "typeRoots": [],
29
+ "useUnknownInCatchVariables": false
30
+ },
31
+ "files": [
32
+ "../../../../../../front_end/models/cpu_profile/cpu_profile.ts",
33
+ "../../../../../../front_end/legacy/legacy-defs.d.ts",
34
+ "../../../../../../front_end/global_typings/global_defs.d.ts",
35
+ "../../../../../../front_end/global_typings/request_idle_callback.d.ts",
36
+ "../../../../../../node_modules/@types/filesystem/index.d.ts",
37
+ "../../../../../../node_modules/@webgpu/types/dist/index.d.ts"
38
+ ],
39
+ "references": [
40
+ {
41
+ "path": "./cpu_profile-tsconfig.json"
42
+ }
43
+ ]
44
+ }
@@ -0,0 +1,55 @@
1
+ import * as Helpers from './helpers/helpers.js';
2
+ import * as Types from './types/types.js';
3
+ type EntryToNodeMap = Map<Types.TraceEvents.SyntheticTraceEntry, Helpers.TreeHelpers.TraceEntryNode>;
4
+ export declare const enum FilterAction {
5
+ MERGE_FUNCTION = "MERGE_FUNCTION",
6
+ COLLAPSE_FUNCTION = "COLLAPSE_FUNCTION",
7
+ COLLAPSE_REPEATING_DESCENDANTS = "COLLAPSE_REPEATING_DESCENDANTS",
8
+ RESET_CHILDREN = "RESET_CHILDREN",
9
+ UNDO_ALL_ACTIONS = "UNDO_ALL_ACTIONS"
10
+ }
11
+ export interface UserFilterAction {
12
+ type: FilterAction;
13
+ entry: Types.TraceEvents.SyntheticTraceEntry;
14
+ }
15
+ export interface PossibleFilterActions {
16
+ [FilterAction.MERGE_FUNCTION]: boolean;
17
+ [FilterAction.COLLAPSE_FUNCTION]: boolean;
18
+ [FilterAction.COLLAPSE_REPEATING_DESCENDANTS]: boolean;
19
+ [FilterAction.RESET_CHILDREN]: boolean;
20
+ [FilterAction.UNDO_ALL_ACTIONS]: boolean;
21
+ }
22
+ /**
23
+ * This class can take in a thread that has been generated by the
24
+ * RendererHandler and apply certain actions to it in order to modify what is
25
+ * shown to the user. These actions can be automatically applied by DevTools or
26
+ * applied by the user.
27
+ *
28
+ * Once actions are applied, the invisibleEntries() method will return the
29
+ * entries that are invisible, and this is the list of entries that should be
30
+ * removed before rendering the resulting thread on the timeline.
31
+ **/
32
+ export declare class EntriesFilter {
33
+ #private;
34
+ constructor(entryToNode: EntryToNodeMap);
35
+ /**
36
+ * Checks which actions can be applied on an entry. This allows us to only show possible actions in the Context Menu.
37
+ * For example, if an entry has no children, COLLAPSE_FUNCTION will not change the FlameChart, therefore there is no need to show this action as an option.
38
+ **/
39
+ findPossibleActions(entry: Types.TraceEvents.SyntheticTraceEntry): PossibleFilterActions;
40
+ /**
41
+ * Returns the amount of entry descendants that belong to the hidden entries array.
42
+ * **/
43
+ findHiddenDescendantsAmount(entry: Types.TraceEvents.SyntheticTraceEntry): number;
44
+ /**
45
+ * Returns the set of entries that are invisible given the set of applied actions.
46
+ **/
47
+ invisibleEntries(): Types.TraceEvents.TraceEventData[];
48
+ /**
49
+ * Applies an action to hide entries or removes entries
50
+ * from hidden entries array depending on the action.
51
+ **/
52
+ applyFilterAction(action: UserFilterAction): Types.TraceEvents.TraceEventData[];
53
+ isEntryModified(event: Types.TraceEvents.TraceEventData): boolean;
54
+ }
55
+ export {};
@@ -0,0 +1,243 @@
1
+ // Copyright 2023 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+ import * as Platform from '../../core/platform/platform.js';
5
+ import * as Helpers from './helpers/helpers.js';
6
+ import * as Types from './types/types.js';
7
+ /**
8
+ * This class can take in a thread that has been generated by the
9
+ * RendererHandler and apply certain actions to it in order to modify what is
10
+ * shown to the user. These actions can be automatically applied by DevTools or
11
+ * applied by the user.
12
+ *
13
+ * Once actions are applied, the invisibleEntries() method will return the
14
+ * entries that are invisible, and this is the list of entries that should be
15
+ * removed before rendering the resulting thread on the timeline.
16
+ **/
17
+ export class EntriesFilter {
18
+ // Maps from an individual TraceEvent entry to its representation as a
19
+ // RendererEntryNode. We need this so we can then parse the tree structure
20
+ // generated by the RendererHandler.
21
+ #entryToNode;
22
+ // Track the set of invisible entries.
23
+ #invisibleEntries = [];
24
+ // List of entries whose children are modified. This list is used to
25
+ // keep track of entries that should be identified in the UI as modified.
26
+ #modifiedVisibleEntries = [];
27
+ // Cache for descendants of entry that have already been gathered. The descendants
28
+ // will never change so we can avoid running the potentially expensive search again.
29
+ #entryToDescendantsMap = new Map();
30
+ constructor(entryToNode) {
31
+ this.#entryToNode = entryToNode;
32
+ }
33
+ /**
34
+ * Checks which actions can be applied on an entry. This allows us to only show possible actions in the Context Menu.
35
+ * For example, if an entry has no children, COLLAPSE_FUNCTION will not change the FlameChart, therefore there is no need to show this action as an option.
36
+ **/
37
+ findPossibleActions(entry) {
38
+ const entryNode = this.#entryToNode.get(entry);
39
+ if (!entryNode) {
40
+ // Invalid node was given, return no possible actions.
41
+ return {
42
+ ["MERGE_FUNCTION" /* FilterAction.MERGE_FUNCTION */]: false,
43
+ ["COLLAPSE_FUNCTION" /* FilterAction.COLLAPSE_FUNCTION */]: false,
44
+ ["COLLAPSE_REPEATING_DESCENDANTS" /* FilterAction.COLLAPSE_REPEATING_DESCENDANTS */]: false,
45
+ ["RESET_CHILDREN" /* FilterAction.RESET_CHILDREN */]: false,
46
+ ["UNDO_ALL_ACTIONS" /* FilterAction.UNDO_ALL_ACTIONS */]: false,
47
+ };
48
+ }
49
+ const entryParent = entryNode.parent;
50
+ const allVisibleDescendants = this.#findAllDescendantsOfNode(entryNode).filter(descendant => !this.#invisibleEntries.includes(descendant));
51
+ const allVisibleRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode).filter(descendant => !this.#invisibleEntries.includes(descendant));
52
+ const allInVisibleDescendants = this.#findAllDescendantsOfNode(entryNode).filter(descendant => this.#invisibleEntries.includes(descendant));
53
+ // If there are children to hide, indicate action as possible
54
+ const possibleActions = {
55
+ ["MERGE_FUNCTION" /* FilterAction.MERGE_FUNCTION */]: entryParent !== null,
56
+ ["COLLAPSE_FUNCTION" /* FilterAction.COLLAPSE_FUNCTION */]: allVisibleDescendants.length > 0,
57
+ ["COLLAPSE_REPEATING_DESCENDANTS" /* FilterAction.COLLAPSE_REPEATING_DESCENDANTS */]: allVisibleRepeatingDescendants.length > 0,
58
+ ["RESET_CHILDREN" /* FilterAction.RESET_CHILDREN */]: allInVisibleDescendants.length > 0,
59
+ ["UNDO_ALL_ACTIONS" /* FilterAction.UNDO_ALL_ACTIONS */]: this.#invisibleEntries.length > 0,
60
+ };
61
+ return possibleActions;
62
+ }
63
+ /**
64
+ * Returns the amount of entry descendants that belong to the hidden entries array.
65
+ * **/
66
+ findHiddenDescendantsAmount(entry) {
67
+ const entryNode = this.#entryToNode.get(entry);
68
+ if (!entryNode) {
69
+ return 0;
70
+ }
71
+ const allDescendants = this.#findAllDescendantsOfNode(entryNode);
72
+ return allDescendants.filter(descendant => this.invisibleEntries().includes(descendant)).length;
73
+ }
74
+ /**
75
+ * Returns the set of entries that are invisible given the set of applied actions.
76
+ **/
77
+ invisibleEntries() {
78
+ return this.#invisibleEntries;
79
+ }
80
+ /**
81
+ * Applies an action to hide entries or removes entries
82
+ * from hidden entries array depending on the action.
83
+ **/
84
+ applyFilterAction(action) {
85
+ // We apply new user action to the set of all entries, and mark
86
+ // any that should be hidden by adding them to this set.
87
+ // Another approach would be to use splice() to remove items from the
88
+ // array, but doing this would be a mutation of the arry for every hidden
89
+ // event. Instead, we add entries to this set and return it as an array at the end.
90
+ const entriesToHide = new Set();
91
+ switch (action.type) {
92
+ case "MERGE_FUNCTION" /* FilterAction.MERGE_FUNCTION */: {
93
+ // The entry that was clicked on is merged into its parent. All its
94
+ // children remain visible, so we just have to hide the entry that was
95
+ // selected.
96
+ entriesToHide.add(action.entry);
97
+ // If parent node exists, add it to modifiedVisibleEntries, so it would be possible to uncollapse its' children.
98
+ const actionNode = this.#entryToNode.get(action.entry) || null;
99
+ const parentNode = actionNode && this.#findNextVisibleParent(actionNode);
100
+ if (parentNode) {
101
+ this.#modifiedVisibleEntries.push(parentNode?.entry);
102
+ }
103
+ break;
104
+ }
105
+ case "COLLAPSE_FUNCTION" /* FilterAction.COLLAPSE_FUNCTION */: {
106
+ // The entry itself remains visible, but all of its descendants are hidden.
107
+ const entryNode = this.#entryToNode.get(action.entry);
108
+ if (!entryNode) {
109
+ // Invalid node was given, just ignore and move on.
110
+ break;
111
+ }
112
+ const allDescendants = this.#findAllDescendantsOfNode(entryNode);
113
+ allDescendants.forEach(descendant => entriesToHide.add(descendant));
114
+ // If there are any children to hide, add selected entry to modifiedVisibleEntries array to identify in the UI that children of the selected entry are modified.
115
+ if (entriesToHide.size > 0) {
116
+ this.#modifiedVisibleEntries.push(action.entry);
117
+ }
118
+ break;
119
+ }
120
+ case "COLLAPSE_REPEATING_DESCENDANTS" /* FilterAction.COLLAPSE_REPEATING_DESCENDANTS */: {
121
+ const entryNode = this.#entryToNode.get(action.entry);
122
+ if (!entryNode) {
123
+ // Invalid node was given, just ignore and move on.
124
+ break;
125
+ }
126
+ const allRepeatingDescendants = this.#findAllRepeatingDescendantsOfNext(entryNode);
127
+ allRepeatingDescendants.forEach(descendant => entriesToHide.add(descendant));
128
+ if (entriesToHide.size > 0) {
129
+ this.#modifiedVisibleEntries.push(action.entry);
130
+ }
131
+ break;
132
+ }
133
+ case "UNDO_ALL_ACTIONS" /* FilterAction.UNDO_ALL_ACTIONS */: {
134
+ this.#invisibleEntries = [];
135
+ this.#modifiedVisibleEntries = [];
136
+ break;
137
+ }
138
+ case "RESET_CHILDREN" /* FilterAction.RESET_CHILDREN */: {
139
+ this.#makeEntryChildrenVisible(action.entry);
140
+ break;
141
+ }
142
+ default:
143
+ Platform.assertNever(action.type, `Unknown EntriesFilter action: ${action.type}`);
144
+ }
145
+ this.#invisibleEntries.push(...entriesToHide);
146
+ return this.#invisibleEntries;
147
+ }
148
+ // The direct parent might be hidden by other actions, therefore we look for the next visible parent.
149
+ #findNextVisibleParent(node) {
150
+ let parent = node.parent;
151
+ while (parent && this.#invisibleEntries.includes(parent.entry)) {
152
+ parent = parent.parent;
153
+ }
154
+ return parent;
155
+ }
156
+ #findAllDescendantsOfNode(root) {
157
+ const cachedDescendants = this.#entryToDescendantsMap.get(root);
158
+ if (cachedDescendants) {
159
+ return cachedDescendants;
160
+ }
161
+ const descendants = [];
162
+ // Walk through all the descendants, starting at the root node.
163
+ const children = [...root.children];
164
+ while (children.length > 0) {
165
+ const childNode = children.shift();
166
+ if (childNode) {
167
+ descendants.push(childNode.entry);
168
+ const childNodeCachedDescendants = this.#entryToDescendantsMap.get(childNode);
169
+ // If the descendants of a child are cached, get them from the cache instead of iterating through them again
170
+ if (childNodeCachedDescendants) {
171
+ descendants.push(...childNodeCachedDescendants);
172
+ }
173
+ else {
174
+ children.push(...childNode.children);
175
+ }
176
+ }
177
+ }
178
+ this.#entryToDescendantsMap.set(root, descendants);
179
+ return descendants;
180
+ }
181
+ #findAllRepeatingDescendantsOfNext(root) {
182
+ // Walk through all the ancestors, starting at the root node.
183
+ const children = [...root.children];
184
+ const repeatingNodes = [];
185
+ const rootIsProfileCall = Types.TraceEvents.isProfileCall(root.entry);
186
+ while (children.length > 0) {
187
+ const childNode = children.shift();
188
+ if (childNode) {
189
+ const childIsProfileCall = Types.TraceEvents.isProfileCall(childNode.entry);
190
+ if ( /* Handle SyntheticProfileCalls */rootIsProfileCall && childIsProfileCall) {
191
+ const rootNodeEntry = root.entry;
192
+ const childNodeEntry = childNode.entry;
193
+ if (Helpers.SamplesIntegrator.SamplesIntegrator.framesAreEqual(rootNodeEntry.callFrame, childNodeEntry.callFrame)) {
194
+ repeatingNodes.push(childNode.entry);
195
+ }
196
+ } /* Handle SyntheticRendererEvents */
197
+ else if (!rootIsProfileCall && !childIsProfileCall) {
198
+ if (root.entry.name === childNode.entry.name) {
199
+ repeatingNodes.push(childNode.entry);
200
+ }
201
+ }
202
+ children.push(...childNode.children);
203
+ }
204
+ }
205
+ return repeatingNodes;
206
+ }
207
+ /**
208
+ * Removes all of the entry children from the
209
+ * invisible entries array to make them visible.
210
+ **/
211
+ #makeEntryChildrenVisible(entry) {
212
+ const entryNode = this.#entryToNode.get(entry);
213
+ if (!entryNode) {
214
+ // Invalid node was given, just ignore and move on.
215
+ return;
216
+ }
217
+ const descendants = this.#findAllDescendantsOfNode(entryNode);
218
+ /**
219
+ * Filter out all descendant of the node
220
+ * from the invisible entries list.
221
+ **/
222
+ this.#invisibleEntries = this.#invisibleEntries.filter(entry => {
223
+ if (descendants.includes(entry)) {
224
+ return false;
225
+ }
226
+ return true;
227
+ });
228
+ /**
229
+ * Filter out all descentants and entry from modified entries
230
+ * list to not show that some entries below those are hidden.
231
+ **/
232
+ this.#modifiedVisibleEntries = this.#modifiedVisibleEntries.filter(iterEntry => {
233
+ if (descendants.includes(iterEntry) || iterEntry === entry) {
234
+ return false;
235
+ }
236
+ return true;
237
+ });
238
+ }
239
+ isEntryModified(event) {
240
+ return this.#modifiedVisibleEntries.includes(event);
241
+ }
242
+ }
243
+ //# sourceMappingURL=EntriesFilter.js.map