You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
suddenly MATLAB process is too slow
7 views (last 30 days)
Show older comments
I am using windows 10 and Matlab 2018b. I have a code was run fast, but suddenly it become so slow. The pseudo code of my code is as follows:
for i=1 : 200
for j=1 : 200
for k=1 : 200
NewMatrix = Archive(i,j)*Archive(k,j) + Archive(j,k)
end
end
end
where the Archive is a matrix of [200,6]
I don't know where is the problem. I am using CPU. could you help me please ?
19 Comments
Rahim Rahim
on 6 Feb 2021
I used the same code, the same input, the same output but the runing is become slow
Adam Danz
on 6 Feb 2021
That's helpful to know but I still have the same quesiton.
The running became slow during the evaluation (i.e, after the first 1000 iterations) or the entire process from iteration #1 became slower compared to previous days?
Rahim Rahim
on 6 Feb 2021
Yes, the running became slow during the evaluation. In the past, it take 1 minutes to run but he become take 30 minutes !!!
Rahim Rahim
on 6 Feb 2021
During iterations yes !
Adam Danz
on 6 Feb 2021
Edited: Adam Danz
on 6 Feb 2021
I was just having the same conversaion a couple of days ago with another user and volunteer in the thread below. There are 3 relevant points to check out in that thread:
- How to hone in on the problem using tic/toc timing or profiling.
- The possibilty that the size of your variables are changing and requiring more resources as interations increase.
- File compression, if you're saving any of the data.
Rahim Rahim
on 6 Feb 2021
@Adam Danz thank you for your email,
I used tic/toc and the time of each iteration have different time, for example iteration 10: Elapsed time is 5.993782 seconds and iteration 20 : 2.00082 seconds .
I don't understand what's the problem right now, please help me
Adam Danz
on 6 Feb 2021
I haven't emailed you; maybe you meant my comment.
Does the timing jump around between 2-6 seconds or is there a pattern in certain sections of the loops?
Did you preallocate the NewMatrix array? That's very important.
Rahim Rahim
on 6 Feb 2021
Edited: Rahim Rahim
on 6 Feb 2021
I did not change anything, 3 days ago the timing was 1 second. Now, between 2 and 6, yes it jumps
Rahim Rahim
on 6 Feb 2021
I think is a problem of size, who can I give a big space to my code ?
Rahim Rahim
on 7 Feb 2021
@Adam Danz If my code requir more resources, what can I do ?
Rahim Rahim
on 7 Feb 2021
@Adam Danz I used my code in another laptop, it run without delay ( run fast ). so the problem in my laptop, I don't exactly know what is the problem !!
Adam Danz
on 7 Feb 2021
> I used preallocate but without any differences.
I highly doubt there was no difference between with/without preallocation if you're storing something within the nested loops. If you're not storing anything, then that's more believable.
> I used my code in another laptop, it run without delay
> Yes, the running became slow during the evaluation.
It sounds like the slow-down is caused both by the machine you're using and the sequence of iterations within the nested loops. The link I provided may help to explain why the process is slowing down during the loops. If there's a difference between machines and you're using the exact same version of code, version of Matlab, and inputs. then obviously the machine is causing the difference. There could be a difference in processors, RAM, etc.
Rahim Rahim
on 8 Feb 2021
@Adam Danz I am so sorry, I putted a lot of questions, and I am begginer on matlab.
This is the results of profile('status')
ProfilerStatus: 'off'
DetailLevel: 'mmex'
Timer: 'performance'
HistoryTracking: 'timestamp'
HistorySize: 1000000
and this the results of profile('info')
FunctionTable: [0×1 struct]
FunctionHistory: [4×0 double]
ClockPrecision: 1.000000000000000e-07
ClockSpeed: 2.592000000000000e+09
Name: 'MATLAB'
Overhead: 0
David Goodmanson
on 8 Feb 2021
Hi Rahim,
One thing worth checking is, with windows 10 bring up the task mananger, click the Perfomance tab, start the program and see what the memory, disk and possibly cpu activity looks like as a function of time.
Adam Danz
on 8 Feb 2021
Please spend some time reading the documentation for that function.
You need to follow the second example, "Profile Function and Save Results as HTML".
Then you need to view the reports and compare them.
And don't forget to take time to formally accept answers that were helpful to you so you can give credit to the volunteers who gave their time to you. This isn't an answer, it's just a comment, but you can go into your profile and see many questions that have been answered and none accepted.
Answers (0)
See Also
Categories
Find more on Performance and Memory in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)