MCPcopy Index your code
hub / github.com/nodejs/node / render

Method render

deps/v8/tools/profview/profview.js:992–1234  ·  view source on GitHub ↗
(newState)

Source from the content-addressed store, hash-verified

990 }
991
992 render(newState) {
993 let oldState = this.currentState;
994
995 if (!newState.file) {
996 this.element.style.display = "none";
997 return;
998 }
999
1000 let width = Math.round(document.documentElement.clientWidth - 20);
1001 let height = Math.round(document.documentElement.clientHeight / 5);
1002
1003 if (oldState) {
1004 if (width === oldState.timelineSize.width &&
1005 height === oldState.timelineSize.height &&
1006 newState.file === oldState.file &&
1007 newState.currentCodeId === oldState.currentCodeId &&
1008 newState.callTree.attribution === oldState.callTree.attribution &&
1009 newState.start === oldState.start &&
1010 newState.end === oldState.end &&
1011 newState.showLogging === oldState.showLogging) {
1012 // No change, nothing to do.
1013 return;
1014 }
1015 }
1016 this.currentState = newState;
1017 this.currentState.timelineSize.width = width;
1018 this.currentState.timelineSize.height = height;
1019
1020 this.element.style.display = "inherit";
1021
1022 let file = this.currentState.file;
1023
1024 const minPixelsPerBucket = 10;
1025 const minTicksPerBucket = 8;
1026 let maxBuckets = Math.round(file.ticks.length / minTicksPerBucket);
1027 let bucketCount = Math.min(
1028 Math.round(width / minPixelsPerBucket), maxBuckets);
1029
1030 // Make sure the canvas has the right dimensions.
1031 this.canvas.width = width;
1032 this.canvas.height = height;
1033
1034 // Make space for the selection text.
1035 height -= this.imageOffset;
1036
1037 let currentCodeId = this.currentState.currentCodeId;
1038
1039 let firstTime = file.ticks[0].tm;
1040 let lastTime = file.ticks[file.ticks.length - 1].tm;
1041 let start = Math.max(this.currentState.start, firstTime);
1042 let end = Math.min(this.currentState.end, lastTime);
1043
1044 this.selectionStart = (start - firstTime) / (lastTime - firstTime) * width;
1045 this.selectionEnd = (end - firstTime) / (lastTime - firstTime) * width;
1046
1047 let filter = filterFromFilterId(this.currentState.callTree.attribution);
1048 let stackProcessor = new CategorySampler(file, bucketCount, filter);
1049 generateTree(file, 0, Infinity, stackProcessor);

Callers

nothing calls this directly

Calls 9

drawSelectionMethod · 0.95
filterFromFilterIdFunction · 0.85
generateTreeFunction · 0.85
removeAllChildrenFunction · 0.85
createElementMethod · 0.80
fillMethod · 0.80
minMethod · 0.45
maxMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected