Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: tools/profview/profile-utils.js

Issue 2753543006: [profiler] Web UI: add summary of opts/deopts. (Closed)
Patch Set: Address reviewer comments Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/profview/index.html ('k') | tools/profview/profview.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/profview/profile-utils.js
diff --git a/tools/profview/profile-utils.js b/tools/profview/profile-utils.js
index 28d55640e01a5fc77d906b56ac0dd1417b180295..9da39b1e9c07f0c84d5081b69a9df17522162a0d 100644
--- a/tools/profview/profile-utils.js
+++ b/tools/profview/profile-utils.js
@@ -476,3 +476,93 @@ function generateTree(
return tickCount;
}
+
+function computeOptimizationStats(file,
+ timeStart = -Infinity, timeEnd = Infinity) {
+ function newCollection() {
+ return { count : 0, functions : [], functionTable : [] };
+ }
+ function addToCollection(collection, code) {
+ collection.count++;
+ let funcData = collection.functionTable[code.func];
+ if (!funcData) {
+ funcData = { f : file.functions[code.func], instances : [] };
+ collection.functionTable[code.func] = funcData;
+ collection.functions.push(funcData);
+ }
+ funcData.instances.push(code);
+ }
+
+ let functionCount = 0;
+ let optimizedFunctionCount = 0;
+ let deoptimizedFunctionCount = 0;
+ let optimizations = newCollection();
+ let eagerDeoptimizations = newCollection();
+ let softDeoptimizations = newCollection();
+ let lazyDeoptimizations = newCollection();
+
+ for (let i = 0; i < file.functions.length; i++) {
+ let f = file.functions[i];
+
+ // Skip special SFIs that do not correspond to JS functions.
+ if (f.codes.length === 0) continue;
+ if (file.code[f.codes[0]].type !== "JS") continue;
+
+ functionCount++;
+ let optimized = false;
+ let deoptimized = false;
+
+ for (let j = 0; j < f.codes.length; j++) {
+ let code = file.code[f.codes[j]];
+ console.assert(code.type === "JS");
+ if (code.kind === "Opt") {
+ optimized = true;
+ if (code.tm >= timeStart && code.tm <= timeEnd) {
+ addToCollection(optimizations, code);
+ }
+ }
+ if (code.deopt) {
+ deoptimized = true;
+ if (code.deopt.tm >= timeStart && code.deopt.tm <= timeEnd) {
+ switch (code.deopt.bailoutType) {
+ case "lazy":
+ addToCollection(lazyDeoptimizations, code);
+ break;
+ case "eager":
+ addToCollection(eagerDeoptimizations, code);
+ break;
+ case "soft":
+ addToCollection(softDeoptimizations, code);
+ break;
+ }
+ }
+ }
+ }
+ if (optimized) {
+ optimizedFunctionCount++;
+ }
+ if (deoptimized) {
+ deoptimizedFunctionCount++;
+ }
+ }
+
+ function sortCollection(collection) {
+ collection.functions.sort(
+ (a, b) => a.instances.length - b.instances.length);
+ }
+
+ sortCollection(eagerDeoptimizations);
+ sortCollection(lazyDeoptimizations);
+ sortCollection(softDeoptimizations);
+ sortCollection(optimizations);
+
+ return {
+ functionCount,
+ optimizedFunctionCount,
+ deoptimizedFunctionCount,
+ optimizations,
+ eagerDeoptimizations,
+ lazyDeoptimizations,
+ softDeoptimizations,
+ };
+}
« no previous file with comments | « tools/profview/index.html ('k') | tools/profview/profview.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698