view m-toolbox/classes/tests/@ut_result_printer/printRuntimeString.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line source

% PRINTRUNTIMESTRING returns a string listing the run time of the tests.
%
% VERSION: $Id: printRuntimeString.m,v 1.2 2010/10/26 12:18:33 hewitson Exp $
%
function res = printRuntimeString(varargin)
  
  urp = varargin{1};
  if nargin>1
    limit = varargin{2};
  else
    limit = inf;
  end
  
  % build array of runtimes
  runtimes = zeros(1,numel(urp.results));
  for kk=1:numel(urp.results)
    r = urp.results(kk);
    runtimes(kk) = r.runtime;
  end
  
  % sort array
  [y,idx] = sort(runtimes,'descend');
  results = urp.results(idx);
  
  res = sprintf('-------- Runtime ----------\n\n');
  for kk=1:numel(results)
    r = results(kk);
    res = [res sprintf('%0.3f s - %s/%s\n', r.runtime, r.testClass, r.testMethod)];
    if kk>limit
      break
    end
  end  
  res = [res sprintf('\n\n----------------------------\n')];
end