function [xmin, contrast] = func_CMAESchrono(m, k, Qhat, Mhat, Ohat, stopeval)
% Computes CMAES minimizers and displays execution time.
% m,k:        dimension and order of current model
% Qhat: k*k   initial value of Q
% Mhat: m*m*m initial value of M
% Ohat: m*k   initial value of O
% stopeval:   number of states after which CMAES should stop

tic;
[~, ~, arindex, arx, xmean] = func_CMAES(m, k, Qhat, Mhat, Ohat, stopeval);
elapsedTime = toc;
disp([' ... finished in ' num2str(elapsedTime) ' seconds.']);

bool = func_empiricalLoss(Mhat, xmean, k) < func_empiricalLoss(Mhat, arx(:, arindex(1)), k);
xmin = arx(:, arindex(1))*(1-bool)+xmean*(bool);  % Return best point of last iteration.
                                                  % Notice that xmean is expected to be even
                                                  % better.

contrast = func_empiricalLoss(Mhat, xmin, k);
