Commit fdbb026
committed
perf: optimize plotting pipeline and reduce allocations
- Reused Point2D.Double instances in Plotter to avoid per-row allocations
→ replaces new Point2D.Double() calls with setLocation() in hot loops
- Hoisted plot type lookup out of the inner loop to reduce repeated branching
- Cached FG colors locally and avoided redundant get/set calls during plotting
- Avoided repeated setStroke() calls by tracking stroke width in Canvas
- Avoided redundant setColor() calls by caching current FG color in Canvas
- Removed unused Canvas.getGraphics() accessor and simplified image lifecycle
- Switched PlotData nodes storage from Vector to ArrayList to remove synchronization overhead
- Minor cleanup in line drawing path (removed redundant operations)
Result: significantly reduced per-frame overhead, fewer allocations, and faster plotting,
especially for large datasets and during interactive redraws.
Profiled using VisualVM1 parent 98eefc9 commit fdbb026
3 files changed
Lines changed: 35 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 114 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | 115 | | |
| 116 | + | |
123 | 117 | | |
124 | 118 | | |
125 | 119 | | |
| |||
138 | 132 | | |
139 | 133 | | |
140 | 134 | | |
141 | | - | |
142 | 135 | | |
143 | 136 | | |
144 | 137 | | |
| |||
345 | 338 | | |
346 | 339 | | |
347 | 340 | | |
348 | | - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
349 | 345 | | |
350 | 346 | | |
351 | 347 | | |
352 | | - | |
353 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
354 | 352 | | |
355 | 353 | | |
356 | 354 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
242 | | - | |
| 241 | + | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 81 | + | |
86 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
| |||
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
95 | | - | |
| 98 | + | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
100 | | - | |
101 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
| |||
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
130 | | - | |
| 135 | + | |
| 136 | + | |
131 | 137 | | |
132 | 138 | | |
133 | | - | |
| 139 | + | |
134 | 140 | | |
135 | 141 | | |
136 | 142 | | |
137 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
138 | 147 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 148 | + | |
145 | 149 | | |
146 | | - | |
147 | 150 | | |
148 | 151 | | |
149 | | - | |
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
| |||
157 | 159 | | |
158 | 160 | | |
159 | 161 | | |
160 | | - | |
161 | | - | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| |||
0 commit comments