diff --git a/tests/read_trs_files.sh b/tests/read_trs_files.sh index 5213e3979..2bda71769 100755 --- a/tests/read_trs_files.sh +++ b/tests/read_trs_files.sh @@ -8,6 +8,7 @@ declare -a failed_tests=(""); declare -a xpassed_tests=(""); # Parse TRS Files +tosort="" for file in $1 ; do # Find number of tests run in trs file ((total += `grep number-tests $file | cut -d: -f3`)) @@ -20,6 +21,9 @@ for file in $1 ; do failed_tests=("${failed_tests[@]}" "$failedfile"); done fi + + time=`grep cputime $file | cut -d: -f3` + tosort=`echo $tosort\| $file ' - ' $time:` done ((passed=$total-$failed)); @@ -37,10 +41,15 @@ for file in $2 ; do xpassed_tests=("${xpassed_tests[@]}" "$xpassedfile"); done fi + + time=`grep cputime $file | cut -d: -f3` + tosort=`echo $tosort\| $file ' - ' $time:` done ((xfailed=$total_xfail-$xpassed)); ((total+=$total_xfail)); +timing=`echo $tosort | tr ":" "\n" | sort -rn -k4 | sed -e 's/$/:/' | head -n10` + # Determine if we are parsing Matlab or Octave trs files if [ `grep -c '.m.trs' <<< $1` -eq 0 ]; then prg='OCTAVE'; @@ -81,4 +90,12 @@ if [ $xpassed -gt 0 ] ; then echo '| * '$modfile >> $outfile done fi +echo '|' >> $outfile +echo '| LIST OF 10 SLOWEST TESTS:' >> $outfile +if [ "$prg" == "MATLAB" ]; then + timing=`sed 's/\.m\.trs/\.mod/g' <<< $timing` +else + timing=`sed 's/\.o\.trs/\.mod/g' <<< $timing` +fi +echo $timing | tr ':' '\n' | sed -e 's/^[ \t]*//' | sed '/^$/d' >> $outfile echo >> $outfile diff --git a/tests/run_all_unitary_tests.m b/tests/run_all_unitary_tests.m index 8707a8c81..ee429481e 100644 --- a/tests/run_all_unitary_tests.m +++ b/tests/run_all_unitary_tests.m @@ -43,5 +43,6 @@ else fprintf(fid,':number-tests: %d\n', counter); fprintf(fid,':number-failed-tests: 0\n'); end +fprintf(fid,':cputime: %f\n',0.0); fclose(fid); exit diff --git a/tests/run_block_byte_tests_matlab.m b/tests/run_block_byte_tests_matlab.m index c9be02120..530d2f7a8 100644 --- a/tests/run_block_byte_tests_matlab.m +++ b/tests/run_block_byte_tests_matlab.m @@ -38,6 +38,7 @@ failedBlock = {}; num_block_tests = 0; cd([top_test_dir filesep 'block_bytecode']); has_optimization_toolbox = user_has_matlab_license('optimization_toolbox'); +cput = cputime; for blockFlag = 0:1 for bytecodeFlag = 0:1 default_solve_algo = 2; @@ -128,6 +129,7 @@ for blockFlag = 0:1 end end end +ecput = cputime - cput; delete('wsMat.mat') cd(getenv('TOP_TEST_DIR')); fid = fopen('run_block_byte_tests_matlab.m.trs', 'w+'); @@ -141,5 +143,6 @@ else fprintf(fid,':number-tests: %d\n', num_block_tests); fprintf(fid,':number-failed-tests: 0\n'); end +fprintf(fid,':cputime: %f\n', ecput); fclose(fid); exit; diff --git a/tests/run_block_byte_tests_octave.m b/tests/run_block_byte_tests_octave.m index 5312c96d0..a915e9752 100644 --- a/tests/run_block_byte_tests_octave.m +++ b/tests/run_block_byte_tests_octave.m @@ -40,6 +40,7 @@ putenv("GNUTERM", "dumb") failedBlock = {}; num_block_tests = 0; cd([top_test_dir filesep 'block_bytecode']); +cput = cputime; for blockFlag = 0:1 for bytecodeFlag = 0:1 ## Recall that solve_algo=7 and stack_solve_algo=2 are not supported @@ -130,8 +131,8 @@ for blockFlag = 0:1 endfor endfor endfor +ecput = cputime - cput; delete('wsOct'); - cd(getenv('TOP_TEST_DIR')); fid = fopen('run_block_byte_tests_octave.o.trs', 'w+'); if size(failedBlock,2) > 0 @@ -144,6 +145,7 @@ else fprintf(fid,':number-tests: %d\n', num_block_tests); fprintf(fid,':number-failed-tests: 0\n'); end +fprintf(fid,':cputime: %f\n', ecput); fclose(fid); ## Local variables: ## mode: Octave diff --git a/tests/run_reporting_test_matlab.m b/tests/run_reporting_test_matlab.m index 4cd152fd6..1f7405e22 100644 --- a/tests/run_reporting_test_matlab.m +++ b/tests/run_reporting_test_matlab.m @@ -57,5 +57,6 @@ else fprintf(fid,':number-failed-tests: 0\n'); fprintf(fid,':list-of-passed-tests: run_reporting_test_matlab.m\n'); end +fprintf(fid,':cputime: %f\n',0.0); fclose(fid); -exit; \ No newline at end of file +exit; diff --git a/tests/run_reporting_test_octave.m b/tests/run_reporting_test_octave.m index 6c37f8718..0f10f5eb6 100644 --- a/tests/run_reporting_test_octave.m +++ b/tests/run_reporting_test_octave.m @@ -61,6 +61,7 @@ else fprintf(fid,':number-failed-tests: 0\n'); fprintf(fid,':list-of-passed-tests: run_reporting_test_octave.m\n'); end +fprintf(fid,':cputime: %f\n',0.0); fclose(fid); ## Local variables: diff --git a/tests/run_test_matlab.m b/tests/run_test_matlab.m index 43d2d69c5..f6686ef70 100644 --- a/tests/run_test_matlab.m +++ b/tests/run_test_matlab.m @@ -31,6 +31,9 @@ cd(directory); disp(''); disp(['*** TESTING: ' modfile ' ***']); + +cput = cputime; +save(['wsMat' testfile '.mat']); try dynare([testfile ext], 'console') testFailed = false; @@ -38,8 +41,14 @@ catch exception printMakeCheckMatlabErrMsg(strtok(getenv('FILESTEM')), exception); testFailed = true; end +top_test_dir = getenv('TOP_TEST_DIR'); +[modfile, name] = strtok(getenv('FILESTEM')); +[directory, testfile, ext] = fileparts([top_test_dir '/' modfile]); +load(['wsMat' testfile '.mat']); +ecput = cputime - cput; +delete(['wsMat' testfile '.mat']); -cd(getenv('TOP_TEST_DIR')); +cd(top_test_dir); name = strtok(getenv('FILESTEM')); fid = fopen([name '.m.trs'], 'w'); if fid < 0 @@ -58,5 +67,6 @@ else fprintf(fid,':number-failed-tests: 0\n'); fprintf(fid,':list-of-passed-tests: %s\n', [name '.mod']); end +fprintf(fid,':cputime: %f\n', ecput); fclose(fid); exit; diff --git a/tests/run_test_octave.m b/tests/run_test_octave.m index b78e25ee5..9137bf3d5 100644 --- a/tests/run_test_octave.m +++ b/tests/run_test_octave.m @@ -38,8 +38,11 @@ setenv("GNUTERM", "dumb"); name = getenv("FILESTEM"); [directory, testfile, ext] = fileparts([top_test_dir '/' name]); cd(directory); + printf("\n*** TESTING: %s ***\n", name); +cput = cputime; +save(['wsOct' testfile '.mat']); try dynare([testfile ext]) testFailed = false; @@ -47,10 +50,14 @@ catch printMakeCheckOctaveErrMsg(getenv("FILESTEM"), lasterror); testFailed = true; end_try_catch - top_test_dir = getenv('TOP_TEST_DIR'); -cd(top_test_dir); name = getenv("FILESTEM"); +[directory, testfile, ext] = fileparts([top_test_dir '/' name]); +load(['wsOct' testfile '.mat']); +ecput = cputime - cput; +delete(['wsOct' testfile '.mat']); + +cd(top_test_dir); fid = fopen([name '.o.trs'], 'w+'); if testFailed fprintf(fid,':test-result: FAIL\n'); @@ -63,6 +70,7 @@ else fprintf(fid,':number-failed-tests: 0\n'); fprintf(fid,':list-of-passed-tests: %s\n', [name '.mod']); end +fprintf(fid,':cputime: %f\n', ecput); fclose(fid); ## Local variables: