close all
clear all
clc

%% Setup
x = [1 1 1 2 2 2 4 4 4 8 8 8 16 16 16];
y = [1 10 100 1 10 100 1 10 100 1 10 100 1 10 100];

%w = postgreSQL avec index
w = [8.121000003 4.13846 3.291871 22.4041 4.690509999 4.530954 23.08765 8.679785 8.1999305 32.082475 15.5278825 24.46524162 51.9979625 46.05269563 43.27162731];
%z = SQLite avec index
z = [6.293200001 6.70365 4.399934 10.2067 9.512 9.020548999 17.967625 17.8257 17.4533525 34.8385125 35.7754325 47.02815588 124.0959875 110.9640481 106.2601662];

%w = postgreSQL sans index
w_2 = [21.9884 17.7926 17.477875 35.0993 20.50742 20.2429905 46.4254 32.47261 60.79028325 112.5087625 85.97759625 109.1950675 125.1214187 164.2417025 197.614023];
%z = SQLite sans index
z_2 = [5.82 4.648440001 4.363905 13.2418 8.525235 8.8946215 20.9488 20.724305 27.124623 65.5046875 68.1318675 54.121952 115.5187938 113.6181931 103.9685138];

%% Plot avec index
figure
% create coordinate matrices using meshgrid
[X, Y] = meshgrid(unique(x), unique(y));

% reshape z and w data into matrix form
Z = reshape(z, numel(unique(y)), numel(unique(x)));
W = reshape(w, numel(unique(y)), numel(unique(x)));

% create first surface plot
hSurface = surf(X, Y, Z);
set(hSurface, 'FaceColor',[1 0 0], 'FaceAlpha',0.5, 'EdgeAlpha', 0);
%colormap('winter'); % set color map
%shading('interp'); % set shading to interpolate colors
hold on

% create second surface plot and set transparency
hSurface2 = surf(X, Y, W);

% add legend
legend('Temps moyen avec SQLite', 'Temps moyen avec PostgreSQL (avec index)')
% add labels
xlabel("Nombre de fil d'exécution");
ylabel("Nombre d'itération par requête");
zlabel('Temps moyen (ms)');
title('Performance des 2 différents SGBD');

