Testsuite: remove useless debug mode from several .m tests

The output is always useful (and even needed in case of test failure).
remove-priordens
Sébastien Villemot 2023-11-16 09:33:27 +01:00
parent 742a3101b1
commit 56ed5bff43
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
4 changed files with 52 additions and 114 deletions

View File

@ -1,5 +1,3 @@
debug = false;
source_dir = getenv('source_root');
addpath([source_dir filesep 'matlab']);
@ -7,10 +5,8 @@ dynare_config;
testFailed = 0;
if ~debug
skipline()
disp('*** TESTING: cyclereduction.m ***');
end
skipline()
disp('*** TESTING: cyclereduction.m ***');
matlab_cr_path = [source_dir filesep 'matlab' filesep 'missing' filesep 'mex' filesep 'cycle_reduction'];
addpath(matlab_cr_path);
@ -37,15 +33,11 @@ try
R = norm(C+B*X1+A*X1*X1,1);
if (R > cvg_tol)
testFailed = testFailed+1;
if debug
dprintf('Matlab cycle_reduction solution is wrong')
end
dprintf('Matlab cycle_reduction solution is wrong')
end
catch
testFailed = testFailed+1;
if debug
dprintf('Matlab cycle_reduction failed')
end
dprintf('Matlab cycle_reduction failed')
end
% 2. Solve the equation with the Fortran cycle reduction algorithm
@ -56,36 +48,28 @@ try
R = norm(C+B*X2+A*X2*X2,1);
if (R > cvg_tol)
testFailed = testFailed+1;
if debug
dprintf('Fortran cycle_reduction solution is wrong')
end
dprintf('Fortran cycle_reduction solution is wrong')
end
catch
testFailed = testFailed+1;
if debug
dprintf('Fortran cycle_reduction failed')
end
dprintf('Fortran cycle_reduction failed')
end
% 3. Compare solutions of the Fortran and Matlab routines
if (norm(X1 - X2, 1) > cvg_tol)
testFailed = testFailed+1;
if debug
dprintf('Fortran and Matlab cycle reduction solutions differ');
end
dprintf('Fortran and Matlab cycle reduction solutions differ');
end
% Compare the Fortran and Matlab execution time
if debug
if tElapsed1<tElapsed2
skipline()
dprintf('Matlab cyclic reduction is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
skipline()
else
skipline()
dprintf('Fortran cyclic reduction is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline()
end
if tElapsed1<tElapsed2
skipline()
dprintf('Matlab cyclic reduction is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
skipline()
else
skipline()
dprintf('Fortran cyclic reduction is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline()
end
t1 = clock;

View File

@ -1,5 +1,3 @@
debug = false;
source_dir = getenv('source_root');
addpath([source_dir filesep 'matlab']);
@ -7,10 +5,8 @@ dynare_config;
testFailed = 0;
if ~debug
skipline()
disp('*** TESTING: logarithmicreduction.m ***');
end
skipline()
disp('*** TESTING: logarithmicreduction.m ***');
matlab_cr_path = [source_dir filesep 'matlab' filesep 'missing' filesep 'mex' filesep 'logarithmic_reduction'];
addpath(matlab_cr_path);
@ -37,15 +33,11 @@ try
R = norm(C+B*X1+A*X1*X1,1);
if (R > cvg_tol)
testFailed = testFailed+1;
if debug
dprintf('Matlab logarithmic_reduction solution is wrong')
end
dprintf('Matlab logarithmic_reduction solution is wrong')
end
catch
testFailed = testFailed+1;
if debug
dprintf('Matlab logarithmic_reduction failed')
end
dprintf('Matlab logarithmic_reduction failed')
end
% 2. Solve the equation with the Fortran logarithmic reduction algorithm
@ -56,36 +48,28 @@ try
R = norm(C+B*X2+A*X2*X2,1);
if (R > cvg_tol)
testFailed = testFailed+1;
if debug
dprintf('Fortran logarithmic_reduction solution is wrong')
end
dprintf('Fortran logarithmic_reduction solution is wrong')
end
catch
testFailed = testFailed+1;
if debug
dprintf('Fortran logarithmic_reduction failed')
end
dprintf('Fortran logarithmic_reduction failed')
end
% 3. Compare solutions of the Fortran and Matlab routines
if (norm(X1 - X2, 1) > cvg_tol)
testFailed = testFailed+1;
if debug
dprintf('Fortran and Matlab logarithmic reduction solutions differ');
end
dprintf('Fortran and Matlab logarithmic reduction solutions differ');
end
% Compare the Fortran and Matlab execution time
if debug
if tElapsed1<tElapsed2
skipline()
dprintf('Matlab logarithmic reduction is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
skipline()
else
skipline()
dprintf('Fortran logarithmic reduction is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline()
end
if tElapsed1<tElapsed2
skipline()
dprintf('Matlab logarithmic reduction is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
skipline()
else
skipline()
dprintf('Fortran logarithmic reduction is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline()
end
t1 = clock;

View File

@ -1,5 +1,3 @@
debug = false;
source_dir = getenv('source_root');
addpath([source_dir filesep 'matlab']);
@ -9,10 +7,8 @@ cd solver-test-functions
testFailed = 0;
if ~debug
skipline()
disp('*** TESTING: nonlinearsolvers.m ***');
end
skipline()
disp('*** TESTING: nonlinearsolvers.m ***');
tolf = 1e-6;
tolx = 1e-6;
@ -62,31 +58,23 @@ for i=1:length(objfun)
if isequal(func2str(objfun{i}), 'powell2')
if ~errorflag
testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i}))
end
dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i}))
end
elseif isequal(func2str(objfun{i}), 'trigonometric')
% FIXME block_trust_region (mex) fails, with exit code equal to 4, but not trust_region (matlab). Would be nice to undertsand the difference.
if ~errorflag
testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i}))
end
dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i}))
end
else
if errorflag || norm(objfun{i}(x))>tolf
testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver (mex) failed on %s function (norm(f(x))=%s).', func2str(objfun{i}), num2str(norm(objfun{i}(x))))
end
dprintf('Nonlinear solver (mex) failed on %s function (norm(f(x))=%s).', func2str(objfun{i}), num2str(norm(objfun{i}(x))))
end
end
catch
testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver (mex) failed on %s function.', func2str(objfun{i}))
end
dprintf('Nonlinear solver (mex) failed on %s function.', func2str(objfun{i}))
end
end
@ -111,29 +99,21 @@ for i=1:length(objfun)
if isequal(func2str(objfun{i}), 'powell2')
if ~errorflag
testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i}))
end
dprintf('Nonlinear solver is expected to fail on %s function but did not return an error.', func2str(objfun{i}))
end
if info~=3
testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver is expected to fail on %s function with info==3 but did not the correct value of info.', func2str(objfun{i}))
end
dprintf('Nonlinear solver is expected to fail on %s function with info==3 but did not the correct value of info.', func2str(objfun{i}))
end
else
if errorflag
testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver failed on %s function (info=%s).', func2str(objfun{i}), int2str(info))
end
dprintf('Nonlinear solver failed on %s function (info=%s).', func2str(objfun{i}), int2str(info))
end
end
catch
testFailed = testFailed+1;
if debug
dprintf('Nonlinear solver failed on %s function.', func2str(objfun{i}))
end
dprintf('Nonlinear solver failed on %s function.', func2str(objfun{i}))
end
end

View File

@ -1,5 +1,3 @@
debug = true;
source_dir = getenv('source_root');
addpath([source_dir filesep 'matlab']);
@ -7,10 +5,8 @@ dynare_config;
testFailed = 0;
if ~debug
skipline()
disp('*** TESTING: riccatiupdate.m ***');
end
skipline()
disp('*** TESTING: riccatiupdate.m ***');
t0 = clock;
@ -57,28 +53,22 @@ try
R = norm(Ptmp_fortran-Ptmp_matlab,1);
if (R > tol)
testFailed = testFailed+1;
if debug
dprintf('The Fortran Riccati update is wrong')
end
dprintf('The Fortran Riccati update is wrong')
end
catch
testFailed = testFailed+1;
if debug
dprintf('Fortran Riccati update failed')
end
dprintf('Fortran Riccati update failed')
end
% Compare the Fortran and Matlab execution time
if debug
if tElapsed1<tElapsed2
skipline()
dprintf('Matlab Riccati update is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
skipline()
else
skipline()
dprintf('Fortran Riccati update is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline()
end
if tElapsed1<tElapsed2
skipline()
dprintf('Matlab Riccati update is %5.2f times faster than its Fortran counterpart.', tElapsed2/tElapsed1)
skipline()
else
skipline()
dprintf('Fortran Riccati update is %5.2f times faster than its Matlab counterpart.', tElapsed1/tElapsed2)
skipline()
end
% Compare results after multiple calls