Skip to content

Commit

Permalink
[entropy] improve performance of entropy calcs
Browse files Browse the repository at this point in the history
by not recalculating data on the leading edge of the debounced
recalculation action. For big trees (which take >500ms of time to
redraw) the main thread is still blocked for roughly the same amount of
time, but the tree is redrawn faster. For small trees which redraw
quicker than that the entropy doesn't update until the debounce 500ms
timeout is reached, resulting in slightly odd behaviour.

(Reducing this timout also results in less-than-ideal behaviour as
(e.g.) dragging the date range of a tree results in interruptions while
the entropy calcs run which is worse IMO.)
  • Loading branch information
jameshadfield committed Oct 28, 2024
1 parent 35e4ca6 commit 2dce56c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/actions/entropy.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const updateEntropyVisibility = debounce((dispatch, getState) => {
) {return;}
const [data, maxYVal] = calcEntropyInView(tree.nodes, tree.visibility, entropy.selectedCds, entropy.showCounts);
dispatch({type: types.ENTROPY_DATA, data, maxYVal});
}, 500, { leading: true, trailing: true });
}, 500, { leading: false, trailing: true });

/**
* Returns a thunk which makes zero or one dispatches to update the entropy reducer
Expand Down

0 comments on commit 2dce56c

Please sign in to comment.