# How to find the efficiency of an algorithm?

6 Ansichten (letzte 30 Tage)
Sadiq Akbar am 9 Feb. 2023
Bearbeitet: Sadiq Akbar am 9 Feb. 2023
I have an algorithm fpa1. How can I find its efficiency? All the required files are in the attachment. You can run the main file to run the algorithm. But how to find its efficiency?
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Tushar Behera am 9 Feb. 2023
I am assuming you want to know how efficient your code is.
You can utilise MATLAB's "profile" built-in function to gauge how effective your code is. The "profile" function creates a report that includes performance data and the amount of time spent in each function. The "tik" and "toc" functions can also be used to calculate how long it takes a chunk of code to run.
For example;
profile on
n = 100;
M = magic(n);
profile viewer
%%%%
tic;
n = 100;
M = magic(n);
toc;
Regards,
Tushar
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Sadiq Akbar am 9 Feb. 2023
Bearbeitet: Sadiq Akbar am 9 Feb. 2023
Thanks a lot dear Tushar Behera for your kind response. Yes, you are right. I have already included the tic and toc commands inside, but in my case the parametres change i.e., in 1st case:
u=[-25 50];
and run it, so it gives me execution time. Then I increase parametrs to 3 as below:
u=[-5 5 65];
and again run it, so it gives me different time. Again I change my parameters to 4 as below:
u=[-20 5 35 -35];
and I run it and this time it gives me different time. So, I am confused which time should I take for its efficiency?

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Troubleshooting in Polyspace Products for Ada finden Sie in Help Center und File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by