[ 
https://issues.apache.org/jira/browse/PIVOT-198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12743193#action_12743193
 ] 

Greg Brown commented on PIVOT-198:
----------------------------------

I just ran a test to see what kind of numbers we are looking at here. For sure, 
updating individual path elements is faster. However, the gain would be 
unnoticeable to most users.

For 1,000 simulated selected paths, in the worst-case scenario of updating all 
of them, the numbers were as follows (averaged over 10,000 test runs): 

Update: 0.0342ms; new: 0.2818ms

So, updating 1,000 paths took 0.03ms, whereas replacing them took 0.28ms. 
Neither one is going to be noticeable to the user, and 1,000 items is a pretty 
extreme case. Also, this performance hit is only incurred when tree data is 
actually modified when a large number of items are selected - this isn't a 
situation we're likely to run into very often.

On the other hand, asking for a tree view's current selection may happen fairly 
often. Here's the results of copying the entire path structure vs. returning an 
immutable list:

Copy: 0.2521ms; get: 0.0008ms

Either way you look at it, the numbers are negligible. However, since the 
performance penalty of updating the selection is only paid when the model 
changes under an existing selection, and callers may often be asking for the 
current selection state, I would suggest that using immutable paths is the 
better alternative.


> Create ImmutablePath class; update TreeView to use ImmutableList in 
> getSelectedPaths()
> --------------------------------------------------------------------------------------
>
>                 Key: PIVOT-198
>                 URL: https://issues.apache.org/jira/browse/PIVOT-198
>             Project: Pivot
>          Issue Type: Improvement
>          Components: wtk
>    Affects Versions: 1.3
>            Reporter: Greg Brown
>            Assignee: Todd Volkert
>            Priority: Minor
>             Fix For: 1.3
>
>
> Create an ImmutablePath class that extends Path; use these internally in 
> TreeView so we can return an ImmutableList wrapper around the selected paths 
> and avoid the deep copy that we currently perform.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to