suddenly MATLAB process is too slow
7 次查看(过去 30 天)
显示 更早的评论
Rahim Rahim
2021-2-6
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 个评论
Adam Danz
2021-2-6
> suddenly it become so slow
Does that mean it became slow durring evaluation of the loops or one day you ran this in Matlab and the whole process was slower that previously, using the same inputs?
Rahim Rahim
2021-2-6
I used the same code, the same input, the same output but the runing is become slow
Adam Danz
2021-2-6
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
2021-2-6
Yes, the running became slow during the evaluation. In the past, it take 1 minutes to run but he become take 30 minutes !!!
Adam Danz
2021-2-6
编辑:Adam Danz
2021-2-6
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
2021-2-6
@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
2021-2-6
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
2021-2-6
编辑:Rahim Rahim
2021-2-6
I did not change anything, 3 days ago the timing was 1 second. Now, between 2 and 6, yes it jumps
Adam Danz
2021-2-6
I didn't understand that last question. But you haven't answered this one:
Did you preallocate the NewMatrix array? That's very important.
If you haven't preallocated, it will drastically slow down your code.
Rahim Rahim
2021-2-7
@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
2021-2-7
> 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.
Adam Danz
2021-2-7
Here's my recommendation.
Run matlab's profiler on your code on both computers using the exact same version of the code, the exact same inputs and the the exact same release of Matlab. Then compare the reports.
Rahim Rahim
2021-2-8
@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
2021-2-8
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
2021-2-8
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Performance and Memory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)