Skip to content

Commit 2fce115

Browse files
Merge pull request #357 from preactjs/component-timing
Profiler: Only collect timings for components
2 parents 58a1c62 + 06a7e89 commit 2fce115

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

src/adapter/10/options.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ export function setupOptionsV10(
6464
// @ts-ignore
6565
let prevHookName = options.useDebugName;
6666

67-
options.vnode = vnode => {
68-
// const id = getVNodeId(ids, vnode);
69-
// FIXME: Does the negative end thing screw up the profiler?
70-
// storeTime(timings.start, id, 0);
71-
// storeTime(timings.end, id, -1);
72-
if (prevVNodeHook) prevVNodeHook(vnode);
73-
};
74-
7567
// Make sure that we are always the first `option._hook` to be called.
7668
// This is necessary to ensure that our callstack remains consistent.
7769
// Othwerwise we'll end up with an unknown number of frames in-between
@@ -117,25 +109,19 @@ export function setupOptionsV10(
117109
}, 100);
118110

119111
o._diff = o.__b = (vnode: VNode) => {
120-
if (vnode.type !== null) {
112+
if (typeof vnode.type === "function") {
121113
timings.start.set(vnode, performance.now());
122-
123-
if (typeof vnode.type === "function") {
124-
const name = getDisplayName(vnode, config);
125-
recordMark(`${name}_diff`);
126-
}
114+
const name = getDisplayName(vnode, config);
115+
recordMark(`${name}_diff`);
127116
}
128117

129118
if (prevBeforeDiff != null) prevBeforeDiff(vnode);
130119
};
131120

132121
options.diffed = vnode => {
133-
if (vnode.type !== null) {
122+
if (typeof vnode.type === "function") {
134123
timings.end.set(vnode, performance.now());
135-
136-
if (typeof vnode.type === "function") {
137-
endMark(getDisplayName(vnode, config));
138-
}
124+
endMark(getDisplayName(vnode, config));
139125
}
140126

141127
if (prevAfterDiff) prevAfterDiff(vnode);

0 commit comments

Comments
 (0)