이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How can I speedup this code ?
조회 수: 1 (최근 30일)
이전 댓글 표시
How can I speed up this code? when I execute this code take much time
댓글 수: 28
Adam Danz
2020년 1월 3일
Use Matlab's profiler to perform an execution time analysis of your code. It will show you where the bottle neck is.
If there is a loop that you'd like to vectorize, isolate that section, put it into a minimal working example, and someone (including myself) may be able to help out with that.
amenah mwuafaq
2020년 1월 3일
편집: per isakson
2020년 1월 5일
I expected the defect in these lines
if isempty(G{nodo,1})==1
x=size(Y_TX{1,1},1)
g_loc=gf(randi(2*q-1,[l,x]),q);
G{nodo,1}=g_loc;
end;
what you advise me to change in the code to speed up my code
Adam Danz
2020년 1월 4일
If you can provide a minimal working example, we can dig into your code to see if anything can be improved.
Adam Danz
2020년 1월 4일
I removed the comments with the additional attached files and code since it seems to be the same as the code you attached in your question. If those files have been updated, please edit your question and supply the new files. That will help to keep things organized in case other are following this thread.
When I try to run your file, RLNC.m, I get this error because I do not have the windows.jpg files Please attach them an any other files/variables we may need to run your code.
Error using fread
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in RLNC (line 42)
X=fread(fid2);
Also, why are you reading that file twice?
fid=fopen('windows.jpg');
fid2=fopen('windows.jpg');
amenah mwuafaq
2020년 1월 4일
When you execute the code using this image a new file will be formed called data .The problem is when this image changes in a larger size, it takes a long time for the code to be executed.
amenah mwuafaq
2020년 1월 5일
This image took 7 hours to implement
And you can choose any image you have with a large size and notice a lot of time to implement
per isakson
2020년 1월 5일
편집: per isakson
2020년 1월 5일
"I expected the defect in these lines ..." For what reason?
I executed your code with the small image and then the large image for a few minutes. A major part of the time was used by the class, GF (Galois field array), especially the method, vertcat, which was called half a million times.
It isn't realistic to try to optimise GF for speed. Remains to call its methods fewer times. Is that possible?
amenah mwuafaq
2020년 1월 5일
Thanks for trying to help me
What do you suggest I do?
The "gf" function is so necessary that I can't do without it
Adam Danz
2020년 1월 5일
I also ran the profiler on both images and had the same results as per isakson.
The lack of comments and obscure variable names make it difficult to reverse-engineer the goal of the code which prevents me from thinking of potential alternatives. If there's a specific section you'd like to focus on I could suggest faster methods if there are any. But the profiler report didn't put a spot light on any obvious bottlenecks other than very many repeated calls to several functions.
per isakson
2020년 1월 5일
편집: per isakson
2020년 1월 5일
"What do you suggest I do?"
Caveats
- I don't understand the goal of the your code and I will not try to find out based on the code.
- Maybe it isn't possible to improve the speed significantly.
My conclusion from the profiler report is that there is no simple fix to improve the speed significantly. What's your goal regarding speed? Possibly, something can be done with the Parallel Computing Toolbox.
I think you need to rewrite the code based on a thorough understanding of the problem that you want to solve.
amenah mwuafaq
2020년 1월 5일
Code action is a network of nodes that sends an image, then encodes it, then sends it through an intermediate node. The final node receives the image, decodes it, and sends it to node n
As for speed, I need to send and receive pictures at high speed
per isakson
2020년 1월 5일
편집: per isakson
2020년 1월 5일
"send and receive pictures at high speed" To me that sounds impossible to achieve by improving your code.
amenah Muwafaq
2020년 1월 5일
I don't have much time to build code from scratch. What do you recommend that I do?
Walter Roberson
2020년 1월 6일
g_loc=gf(randi(2*q-1,[l,x]),q);
Is that line correct? q is 8, so you are producing random values in the range 1 to 15, which only requires gf(values,4) not gf(values,8) ? When you use gf() the restriction is that the values must be in the range 0 to 2^q-1 not in the range 1 to 2*q-1 . Values in the range 1 to 2*q-1 only requires gf(values, log2(q)+1)
amenah Muwafaq
2020년 1월 7일
편집: amenah Muwafaq
2020년 1월 7일
Walter Roberson Sorry I did not see your question, yes the value of q = 8, but what did you mean in the rest of your questions?
amenah Muwafaq
2020년 1월 7일
Walter Roberson Do you mean to replace this 2*q-1 with this gf(values, log2(q)+1)?
Walter Roberson
2020년 1월 7일
No, I mean you need to decide between
g_loc=gf(randi(2*q-1,[l,x]),q);
which is your existing code that is only using half the capability of your gf, and
g_loc=gf(randi(2^q-1,[l,x]),q);
which uses the full capabilities of the gf .
amenah mwuafaq
2020년 1월 7일
Is there a difference between the two? Can you provide me information about it?
Walter Roberson
2020년 1월 8일
What is the purpose of your creating random galois fields at that point? Why, for example, are you not just creating a fixed one or something based on 0:(l*x-1) ? Or why not just based on randi([0 1], [l,x],1) instead of randi([2*q-1,[l,x],q) ?
amenah Muwafaq
2020년 1월 8일
This is because of the type of coding I'm working on,"Random Linear Network Coding" which depends on the galois fields and random.
Walter Roberson
2020년 1월 8일
Unless you switch to
g_loc=gf(randi([0 2^q-1],[l,x]),q);
then your RLNC system will be more vulerable to data corruption than you expect. The degree to which it is worse will increase greatly as q increases. For q=4 it is only half as good as it should be; for q=5 it is only about 1/6 as good as it should be; for q=8 it would be less than 6% as good as it should be.
amenah mwuafaq
2020년 1월 8일
편집: amenah mwuafaq
2020년 1월 8일
Thank you for helping me.
I changed the equation to
g_loc=gf(randi([0 2^q-1],[l,x]),q);
But the code didn't improve. And I need high speed.
Is there some treatment to improve speed?
채택된 답변
per isakson
2020년 1월 6일
편집: per isakson
2020년 1월 6일
"I don't have much time [...]. What do you recommend that I do?"
Set Specific Goals. Your goal must be clear and well defined.
- Chose a small, a medium and a large picture.
- Your computer system
- Set acceptable execution times, number of seconds, for encoding and decoding, respectively.
- ...
Post a new question with a specific title, one that will catch the eye of someone who knows something about encoding, decoding and Galois fields. Carefully select a handfull of tags.
If you have the Parallel Computing Toolbox, a suitable graphical card and some experience, then assess the potential of parallel operations.
Google might find a FORTRAN or C library that you can use to make a mex-file.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
태그
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 (한국어)