Skip to content

Commit

Permalink
Add timing functions to setDisplayOrder
Browse files Browse the repository at this point in the history
This function is a good candidate for timing: it recurses through all
tree nodes and is called upon initial load and every update of filters
or zoom level.
  • Loading branch information
victorlin committed Oct 21, 2024
1 parent 8a65633 commit a7b4057
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/tree/phyloTree/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { max } from "d3-array";
import {getTraitFromNode, getDivFromNode, getBranchMutations} from "../../../util/treeMiscHelpers";
import { NODE_VISIBLE } from "../../../util/globals";
import { timerStart, timerEnd } from "../../../util/perf";

/** get a string to be used as the DOM element ID
* Note that this cannot have any "special" characters
Expand Down Expand Up @@ -88,6 +89,8 @@ function _getSpaceBetweenSubtrees(numSubtrees, numTips) {
* @returns {undefined}
*/
export const setDisplayOrder = ({nodes, focus}) => {
timerStart("setDisplayOrder");

const numSubtrees = nodes[0].n.children.filter((n) => n.fullTipCount!==0).length;
const numTips = focus ? nodes[0].n.tipCount : nodes[0].n.fullTipCount;
const spaceBetweenSubtrees = _getSpaceBetweenSubtrees(numSubtrees, numTips);
Expand Down Expand Up @@ -135,6 +138,8 @@ export const setDisplayOrder = ({nodes, focus}) => {
/* note that nodes[0] is a dummy node holding each subtree */
nodes[0].displayOrder = undefined;
nodes[0].displayOrderRange = [undefined, undefined];

timerEnd("setDisplayOrder");
};


Expand Down

0 comments on commit a7b4057

Please sign in to comment.