Code in live script run much slow
显示 更早的评论
The new matlab live script functionality is really awesome, thanks matlab team.
But I observe that my code run considerably slower in live script than in the command line. Just out of curiousity, is this an expected result for a newly created function or there is some way to configure the amount of resource allocation for live script? Thanks.
5 个评论
Lukas Müller
2017-11-25
编辑:Lukas Müller
2017-11-25
just want to add my case to the needed update in performance in matlab livescript. The following code
x1_ini = -147143866;
x2_ini = 3391949;
v1_ini = -0.68641;
v2_ini = -30.2659;
max_dev = 0.1*6371;
earth_sun = 149600000;
orbit = 2*pi*earth_sun;
v = norm(v1_ini+v2_ini);
dt = 1;
while true
n = 1;
while v*dt*n < (orbit-max_dev)
n = n+1;
end
if v*dt*n + v*dt > (orbit+max_dev)
break
end
dt = dt+1;
end
dt_max = dt-1; %= 24
takes a couple of seconds as .m file and isn't yet finished computing after 3 hours as livescript ...
Noam Segev
2019-2-24
编辑:per isakson
2020-8-7
It is a bit ungainly, but you can save the file as .m file and run the heavy sections from this file, and then continue with livescript for sections that needs the represenations.
Matt J
2020-2-28
Does anyone know if the speed issue extends to Live Functions?
per isakson
2020-8-7
编辑:per isakson
2020-8-7
Executions of functions are not affected as far as I can see on R2018b.
I copied the code of the comment above by Lukas Müller into an ordinary m-function and a Live Editor mlx-function. tic/toc reports the same elapse time for the two
>> live_function_test
Elapsed time is 0.145617 seconds.
>> live_function_test_LE % Live Editor
Elapsed time is 0.143375 seconds.
P.S. I did a similar comparison with scripts. The m-script finished in about the same time as the functions. I interupted the live-script after a minute.
feynman feynman
2024-2-8
"
Code in live script run much slow
" is this talking about live script on a local pc (offline) or online? Is running offline still much slower than in m files?
采纳的回答
更多回答(7 个)
Gijs van Oort
2017-5-31
5 个投票
The most annoying I think, is that editing is much slower too. After pressing a key, it takes noticeable time for the character to be shown on the screen. Also walking through the code with the arrow keys and scrolling are really slow. Due to this, I'm now ending up writing my code in a normal .m script and copying it to the .mlx when I'm happy with the results.
2 个评论
Gijs van Oort
2017-6-28
In the LiveScript, I was displaying some very long symbolic equations. I found out that this greatly reduced speed and responsiveness. It was useless anyway; 90% of the displayed equation would be typeset off the screen. After I disabled the displaying of the equations (adding a ; after the assignment), the thing became much faster (but still slower than I would wanted it to be)
Manoj
2024-4-8
I agree with Gijs. Live editor is way slower even on really good spec machines even with R2023b
Prannay Jain
2016-11-15
4 个投票
Yes, the code runs slower in the live script than in the command line. Currently, there is no way to configure the amount of resource allocation for the live script.
I work for MathWorks and I have forwarded this feedback to the appropriate product team.
7 个评论
Xinyu Zhang
2016-11-15
Ninad Chaudhari
2017-11-11
1 year later, The code still runs painfully slow as compared to normal "m" file or command window! Really want to use the live script feature, but the speed just kills it !
Jan Kappen
2018-1-14
Any updates on that? It's still extremely slow. Not only the execution but the input/scrolling as well. Brave new world of web apps...
Ronan Fleming
2018-3-8
Yes, the latency associated with editing of live scripts is frustrating. Any workaround for this?
Pierre-Francois
2018-3-15
编辑:Pierre-Francois
2018-3-15
Any news on this topic? The awful sluggishness of the live script makes this otherwise very promising and appealing tool completely useless. Really too bad !
Jan Kappen
2018-5-13
I have the feeling, being behind a corporate proxy makes things much worse. When I'm at home office without proxy the editor is much quicker. Do you experience the same?
Dom Dwyer
2019-1-14
has this been fixed yet? we can't work with this product currently as it is too slow even on new computers
Tom Anderson
2017-1-9
编辑:Tom Anderson
2017-1-16
2 个投票
Please improve this! It's almost 50% slower to run .mlx versus .m...
I ran a code section for a live file using "Run Section" that took 72.971023 seconds. The same code .m file using "Run Section" took 52.701320 seconds. Repeated this test multiple times and .mlx is always a loser.
That's not very good. It's almost a 50% slowdown. It's not as though there's any extra interactivity between the code, either. Just waiting for the results both times, with the GUI locked up.
1 个评论
Tom Anderson
2017-1-16
编辑:Tom Anderson
2017-1-16
Here's a great example I found to run much slower:
tic
for t = 1:1000000
if ~mod(t, 10000), disp(t), end
end
toc
The live code (.mlx): Elapsed time is 487.6064 seconds.
Hit F9 to run (or run as script): Elapsed time is 0.010989 seconds.
50,000 times slower? What gives?
Florian Blanchet
2019-12-11
2 个投票
Hi,
Can you remove that feature or at least make it clear that is significantly slower and will reduce editor experience ?
How can you provide a feature that is so unusable without make it explicit it is still experimental ?
Ryan
2017-3-25
1 个投票
I will definitely use this feature more when resource allocation improves.
Frieder Wittmann
2018-5-28
0 个投票
Has this been addressed in R2018a? Didn't see anything in the release notes.
2 个评论
Will Perdikakis
2018-8-28
Nope. Still brutally slow edits and execution.
Frieder Wittmann
2019-5-3
We're at 2019b now and despite all the advertisement for the future it is still unusable slow :-(
Juan José Trujillo
2018-9-17
0 个投票
Hi,
I do not know what is the motivation for you to use the live scripts. I really find this a cool way of documenting and something which approaches a bit what you can do in Jupyter Notebooks.
In fact, I have been using successfully Jupyter Notebooks with the matlab engine in the last two years to run matlab code. I have worked that way since I have some python background and did not know live scripts until recently. Just lately I have got in touch with matlabs live scripts through a colleague and we have noticed latency which I do not experience through Jupyter Notebooks. I guess the mechanics here are really different and the Notebook approach almost resembles running bare scripts with a bit of overhead on the matlab engine.
Maybe you can give Jupyter Notebook a try and get better performance and with slightly better documentation capabilities with markdown.
4 个评论
Kouichi C. Nakamura
2018-9-17
Correct me, if I'm wrong, but I thought MATLAB engine for Jupyter notebook is not MATLAB per se. I assumed that many of newly added MATLAB functions or class constructors/methods won't run.
I really do think Markdown is superior to LiveScript's mark up. But if the most of code won't run, I cannot use Jupyter. So I have been wishing that at some point MathWorks might adopt markdown.
Or if there is a way to run official licensed MATLAB for Jupyter, then please let me know.
Frieder Wittmann
2018-9-26
编辑:Frieder Wittmann
2018-9-26
I use Jupyter and like it but still prefer MATLAB due to its build in debugger, profiler and access to the workspace. Also, I like that I can run commands in the command window and combine this with results from scripts.
Juan José Trujillo
2018-11-7
Hi Kouichi, sorry for answering that late. I am not really into it. But, As I understand the Matlab engine in Jupyter is just a thin wrapper which passess commands straight to a headless matlab instance. In fact any time a launch a matlab notebook I get fully new instance of Matlab working in the background. So I think you get the best of both worlds, or almost depending on the application. As Frieder says, still there are several applications that you do not have access to from the Jupyter Notebook.
A really cool application of this is for instance if you work on a remote headless system with long lived sessions. You just turn on and off your graphical interface (web browser) locally and connect to the server when you need it, but the Jupyter server and matlab instance stay alive on the remote side. I think you cannot do this kind of things with the matlab IDE, or correct me if I am wrong.
Kouichi C. Nakamura
2018-12-18
Thank for the information about the backstage of Jupyter. Yeah, that makes sense!
类别
在 帮助中心 和 File Exchange 中查找有关 Integration with Online Platforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!