diff --git a/tests/dataSpeed.mat b/tests/dataSpeed.mat new file mode 100644 index 0000000000000000000000000000000000000000..f1ff477eb1f02c2d20021abb4c7e9dec0510f9e4 --- /dev/null +++ b/tests/dataSpeed.mat @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70f24e53c5f2fb85141ac6289ad5ec8148f58ed3340f431946caf0c4c055f678 +size 20407 diff --git a/tests/speedBenchmark.m b/tests/speedBenchmark.m index 5364c7a348bbc609b38d677649c00ea36ac0f350..4779e1cc666807546a24e9081fa826f291e34501 100644 --- a/tests/speedBenchmark.m +++ b/tests/speedBenchmark.m @@ -3,11 +3,9 @@ clc; close all; clear all; warning off % call of a warning because converting class to a struct in function -% TODO: determinant, inverse matrix, traspose, \ -% TOFIX: eigen, assignment - +% TOFIX: assignment +vct = 10:10:10^3; %% Functions -vct = 10^2:1000:10^5; %%% Reading time readTime = []; @@ -18,14 +16,14 @@ end clear head %% Assignment time -% assignmentTime = []; -% for i = 1:length(vct) -% head = assignmentSpeed(vct(i)); -% assignmentTime = [assignmentTime head]; %#ok<*AGROW> -% end -% clear head -%% -%%% Scalar product time +assignmentTime = []; +for i = 1:length(vct) + head = assignmentSpeed(vct(i)); + assignmentTime = [assignmentTime head]; %#ok<*AGROW> +end +clear head + +%% Scalar product time scalarProductTime = []; for i = 1:length(vct) head = scalarProductSpeed(vct(i)); @@ -33,17 +31,16 @@ for i = 1:length(vct) end clear head -%%% Eigen -% dim = 2:1:10; -% -% eigenTime = []; -% for i = 1:length(vct) -% head = eigenSpeed(vct(i)); -% eigenTime = [eigenTime head]; %#ok<*AGROW> -% end -% clear head +%% Eigen -%%% Sum time +eigenTime = []; +for i = 1:length(vct) + head = eigenSpeed(vct(i)); + eigenTime = [eigenTime head]; %#ok<*AGROW> +end +clear head + +%% Sum time sumTime = []; for i = 1:length(vct) head = sumSpeed(vct(i)); @@ -51,10 +48,45 @@ for i = 1:length(vct) end clear head -%%% Cross product time +%% Cross product time crossProductTime = []; for i = 1:length(vct) head = crossProductSpeed(vct(i)); crossProductTime = [crossProductTime head]; %#ok<*AGROW> end clear head + +%% Transpose time +transposeTime = []; +for i = 1:length(vct) + head = transposeSpeed(vct(i)); + transposeTime = [transposeTime head]; %#ok<*AGROW> +end +clear head + +%% Inverse time +inverseTime = []; +for i = 1:length(vct) + head = inverseSpeed(vct(i)); + inverseTime = [inverseTime head]; %#ok<*AGROW> +end +clear head + +%% Determinant time +determinantTime = []; +for i = 1:length(vct) + head = determinantSpeed(vct(i)); + determinantTime = [determinantTime head]; %#ok<*AGROW> +end +clear head + +%% Mldivide (\) time +mldivideTime = []; +for i = 1:length(vct) + head = mldivideSpeed(vct(i)); + mldivideTime = [mldivideTime head]; %#ok<*AGROW> +end +clear head + +%% Saving data +save('dataSpeed.mat') \ No newline at end of file diff --git a/tests/speedBenchmarkPlot.m b/tests/speedBenchmarkPlot.m index 8f0c91ab180da1271c068dcdc9fc6f72366a4a67..cb8c5c39b1e46e0069fb41dca1c496c3155fd158 100644 --- a/tests/speedBenchmarkPlot.m +++ b/tests/speedBenchmarkPlot.m @@ -1,5 +1,7 @@ % Calling speedBenchmark script -speedBenchmark; +% speedBenchmark; +clc; close all; clear all; +load('dataSpeed.mat') %% Plots plt.stdBlue = [0 0.447 0.741]; @@ -21,34 +23,34 @@ legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) grid on %% Assignment time standard -% figure -% for i = 1:length(vct) -% semilogx(vct(i), speed(i).assignment.std.struct, '.' ,'Color', plt.stdBlue) -% semilogx(vct(i), speed(i).assignment.std.class, '.', 'Color', plt.stdRed) -% hold on -% end -% plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); -% plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); -% title('Assignment time standard'); -% xlabel('Number of elements') -% ylabel('Speed [s]') -% legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) -% grid on -% -% % Assignment time element wise -% figure -% for i = 1:length(vct) -% semilogx(vct(i), speed(i).assignment.elementWise.struct, '.' ,'Color', plt.stdBlue) -% semilogx(vct(i), speed(i).assignment.elementWise.class, '.', 'Color', plt.stdRed) -% hold on -% end -% plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); -% plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); -% title('Assignment time element wise'); -% xlabel('Number of elements') -% ylabel('Speed [s]') -% legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) -% grid on +figure +for i = 1:length(vct) + semilogx(vct(i), assignmentTime(i).std.struct, '.' ,'Color', plt.stdBlue) + semilogx(vct(i), assignmentTime(i).std.class, '.', 'Color', plt.stdRed) + hold on +end +plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); +plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); +title('Assignment time standard'); +xlabel('Number of elements') +ylabel('Speed [s]') +legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) +grid on + +% Assignment time element wise +figure +for i = 1:length(vct) + semilogx(vct(i), assignmentTime(i).elementWise.struct, '.' ,'Color', plt.stdBlue) + semilogx(vct(i), assignmentTime(i).elementWise.class, '.', 'Color', plt.stdRed) + hold on +end +plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); +plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); +title('Assignment time element wise'); +xlabel('Number of elements') +ylabel('Speed [s]') +legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) +grid on %% Scalar product figure @@ -96,16 +98,76 @@ legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) grid on %% Eigenvalues problem time (matrices) -% figure -% for i = 1:length(vct) -% semilogx(vct(i), speed(i).eigen.struct, '.' ,'Color', plt.stdBlue) -% semilogx(vct(i), speed(i).eigen.class, '.', 'Color', plt.stdRed) -% hold on -% end -% plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); -% plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); -% title('Eigenvalues problem time (matrices) '); -% xlabel('Number of elements') -% ylabel('Speed [s]') -% legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) -% grid on \ No newline at end of file +figure +for i = 1:length(vct) + semilogx(vct(i), eigenTime(i).struct, '.' ,'Color', plt.stdBlue) + semilogx(vct(i), eigenTime(i).class, '.', 'Color', plt.stdRed) + hold on +end +plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); +plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); +title('Eigenvalues problem time (matrices) '); +xlabel('Number of elements') +ylabel('Speed [s]') +legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) +grid on + +%% Transpose time (matrices) +figure +for i = 1:length(vct) + semilogx(vct(i), transposeTime(i).struct, '.' ,'Color', plt.stdBlue) + semilogx(vct(i), transposeTime(i).class, '.', 'Color', plt.stdRed) + hold on +end +plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); +plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); +title('Transpose time (matrices)'); +xlabel('Number of elements') +ylabel('Speed [s]') +legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) +grid on + +%% Inverse time (matrices) +figure +for i = 1:length(vct) + semilogx(vct(i), inverseTime(i).struct, '.' ,'Color', plt.stdBlue) + semilogx(vct(i), inverseTime(i).class, '.', 'Color', plt.stdRed) + hold on +end +plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); +plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); +title('Inverse time (matrices)'); +xlabel('Number of elements') +ylabel('Speed [s]') +legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) +grid on + +%% Determinant time (matrices) +figure +for i = 1:length(vct) + semilogx(vct(i), determinantTime(i).struct, '.' ,'Color', plt.stdBlue) + semilogx(vct(i), determinantTime(i).class, '.', 'Color', plt.stdRed) + hold on +end +plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); +plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); +title('Determinant time (matrices)'); +xlabel('Number of elements') +ylabel('Speed [s]') +legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) +grid on + +%% Mldivide (\) time (matrices) +figure +for i = 1:length(vct) + semilogx(vct(i), mldivideTime(i).struct, '.' ,'Color', plt.stdBlue) + semilogx(vct(i), mldivideTime(i).class, '.', 'Color', plt.stdRed) + hold on +end +plt.lgdStruct = plot(nan, nan, 'color', plt.stdBlue); +plt.lgdClass = plot(nan, nan, 'color', plt.stdRed); +title('Mldivide time (matrices)'); +xlabel('Number of elements') +ylabel('Speed [s]') +legend([plt.lgdStruct, plt.lgdClass], {'Struct', 'Class'}) +grid on \ No newline at end of file