function result = obtainTimingForMeasureComputation(result, measureList)
% generate sample vectors and get timing
%
% The goal here is to take at least minumumTestNumber(1) hC-vectors
%   equally distributed over the simplex partitions for the
%   computation of the unified partition. Then, only minimumTestNumber(2)
%   preferably equally distributed vectors shall be used to get the
%   timing for measure calculation. minimumTestNumber(1) is usually
%   much larger than minimumTestNumber(2).

%fprintf(['Testing Measure ' measureList(iMeas).name ' for ' caseNameList{i} ' ..\n']);
    
% ensure that at least minimumTestNumber(1) are generated
sampleNumberPerSimplexPartition = ceil(...
    measureList(1).minimumTestNumber(1) / result.dec.nPS);

% generate hC-vectors per simplex partition
sampleHcMatrix = zeros([...
    result.dec.nPS * sampleNumberPerSimplexPartition, ...
    result.dec.nC]);
for iSimplex = 1:result.dec.nPS
    sampleHcMatrix(...
        (iSimplex-1)*sampleNumberPerSimplexPartition + ...
        (1:sampleNumberPerSimplexPartition), :) = ...
        rand([sampleNumberPerSimplexPartition, result.dec.nC]) * ...
        result.dec.se(...
        result.dec.simplexPartition{iSimplex}.seIndexVector, ...
        :);
end
sampleHcMatrix = sampleHcMatrix';
result.obtainPartitionSamples = size(sampleHcMatrix, 2);

% obtain unified partitions
tic
simplexVector = computePartitionIndexDec(result.dec, ...
    sampleHcMatrix, [], 0);
result.obtainUnifiedTime = toc;
    
% obtain simplex partitions
tic
unifiedVector = computePartitionIndexDec(result.dec, ...
    sampleHcMatrix, [], 1);
result.obtainSimplexTime = toc;

for iMeas = 1:length(measureList)
    
    % compute measure
    thisIndexVector = ceil(...
        rand([1 measureList(iMeas).minimumTestNumber(2)])*...
        size(sampleHcMatrix, 2));
    thisSampleHcMatrix = sampleHcMatrix(:, thisIndexVector);
    thisUnifiedVector = unifiedVector(thisIndexVector);
    
    if isempty(measureList(iMeas).par)
        nPar = 1;
        tic
        tmp = computeMeasureDec(result.dec, 'hC', ...
            {thisUnifiedVector, thisSampleHcMatrix}, ...
            measureList(iMeas).name, ...
            [], 0);
    else
        nPar = size(measureList(iMeas).par, 1);
        tic
        tmp = computeMeasureDec(result.dec, 'hC', ...
            {thisUnifiedVector, thisSampleHcMatrix}, ...
            {measureList(iMeas).name, measureList(iMeas).par}, ...
            [], 0);
    end
    result.(measureList(iMeas).name).computeMeasureTime = toc;
    result.(measureList(iMeas).name).computeMeasureSamples = ...
        size(thisSampleHcMatrix, 2);
    result.(measureList(iMeas).name).computeMeasureNPar = nPar;
    
    % compute real measure
    thisIndexVector = ceil(...
        rand([1 measureList(iMeas).minimumTestNumber(3)])*...
        size(sampleHcMatrix, 2));
    thisSampleHcMatrix = sampleHcMatrix(:, thisIndexVector);
    sampleHMatrix = result.dec.mappingReducedToFull * thisSampleHcMatrix;
    
    if isempty(measureList(iMeas).par)
        nPar = 1;
        tic
        for iSample = 1:size(thisSampleHcMatrix, 2)
            tmp2 = result.dec.measureData.(measureList(iMeas).name).handleHrep(...
                struct('A', result.dec.A, 'h', sampleHMatrix(:, iSample)));
        end
    else
        nPar = size(measureList(iMeas).par, 1);
        tic
        for iSample = 1:size(thisSampleHcMatrix, 2)
            tmp2 = result.dec.measureData.(measureList(iMeas).name).handleHrep(...
                struct('A', result.dec.A, 'h', sampleHMatrix(:, iSample)), ...
                measureList(iMeas).par);
        end
    end
    result.(measureList(iMeas).name).computeRealMeasureTime = toc;
    result.(measureList(iMeas).name).computeRealMeasureSamples = ...
        size(thisSampleHcMatrix, 2);
    result.(measureList(iMeas).name).computeRealMeasureNPar = nPar;
end