mirror of
https://bitbucket.org/Mattrixwv/octavefunctions.git
synced 2025-12-06 18:53:57 -05:00
Added a timer for measuring performance
This commit is contained in:
@@ -11,6 +11,7 @@ palindromes = []; %Holds all the numbers that are palindromes
|
||||
outerCounter = 1;
|
||||
innerCounter = 1;
|
||||
|
||||
startTime = clock(); %This is for timing purposes
|
||||
while(outerCounter < size(numbers)(2))
|
||||
innerCounter = outerCounter; %Once you have multiplied 2 numbers there is no need to multiply them again, so skip what has already been done
|
||||
while(innerCounter < size(numbers)(2))
|
||||
@@ -27,6 +28,8 @@ while(outerCounter < size(numbers)(2))
|
||||
end
|
||||
++outerCounter; %Increment
|
||||
end
|
||||
endTime = clock(); %This is for timing purposes
|
||||
timeTaken = etime(endTime - startTime) %This is for timing purposes
|
||||
|
||||
max(palindromes)
|
||||
|
||||
@@ -36,6 +39,10 @@ clear innerCounter;
|
||||
clear answer;
|
||||
clear numbers;
|
||||
clear palindromes;
|
||||
clear startTime;
|
||||
clear endTime;
|
||||
clear timeTaken;
|
||||
|
||||
|
||||
%This way is slow. I would like to find a faster way
|
||||
%{
|
||||
|
||||
Reference in New Issue
Block a user