Patch Rendering Performance R2025a vs R2021b
Show older comments
I use patch() often for simple realtime visualization of robots in our machines.
Until now we have worked with Matlab R2021b. I am looking at Matlab R2025a for evaluation.
The newer release seems to be slower at rendering patches than the older release. I made a simple script to test this, see below.
On my computer, the script has the following running time:
R2021b: 5.1 seconds
R2025a: 7.1 seconds
Why is the newer version slower? Do I need to handle patch() differently for better performance? Any suggestions?
close all
p = patch('XData', rand(100,1),'YData',rand(100,1),'ZData',rand(100,1));
view(3)
tic()
for idx = 1:100
p.XData = rand(100,1);
p.YData = rand(100,1);
p.ZData = rand(100,1);
drawnow();
end
toc()
5 Comments
Walter Roberson
on 14 Jun 2025
R2021b fails on my machine (operating system incompatibility.)
I tested R2022b. It does seem to average a little faster, but there was considerable overlap in the timings compared to R2025b.
R2022b best 3.655711 worst 4.573829 (around 4.2 was common)
R2025a best 4.245172 worst 4.684883 (around 4.3 was common)
R20211b best 6.205 worst 6.832
R20221b best 6.333 worst 7.311. (6.8 and 6.3 seemed about equally frequent)
Nothing later installed...
Just out of curiosity, have your tried using a constant set of data inside the loop just to see if by the most remote of chances there might be a difference in the rand timing confounding the graphics timing...
Walter Roberson
on 17 Jun 2025
R2021b tested on virtual machine running Windows 10 (hosted on MacOS Sequoia): best 5.246 worst 5.632
R2025a tested on virtual machine running Windows 10 (hosted on MacOS Sequoia): best 8.266 worst 9.197
On the virtual machine, R2025a is visibly slower
Walter Roberson
on 17 Jun 2025
I had the hypothesis that perhaps rand() was slower, so I tried preallocating XD = rand(100,100); and likewise YD and ZD, and then P.XData = rand(:,idx); and similar. The resulting code ran a bit slower on R2025a.
Alexander Jöhl
on 17 Jun 2025
Accepted Answer
More Answers (0)
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!