1function logstat (testscript, threads) 2%LOGSTAT run a GraphBLAS test and log the results to log.txt 3 4% SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2021, All Rights Reserved. 5% SPDX-License-Identifier: Apache-2.0 6 7[debug, compact, malloc, covered] = GB_mex_debug ; 8 9clast = grb_get_coverage ; 10 11if (nargin < 2) 12 % by default, use 4 threads and a tiny chunk size of 1 13 threads {1} = [4 1] ; 14else 15 % only the # of threads is specified; also set the chunk size to 1 16 if (isscalar (threads) && isnumeric (threads)) 17 threads = max (threads, 1) ; 18 t {1} = [threads 1] ; 19 threads = t ; 20 end 21end 22 23ntrials = length (threads) ; 24 25for trial = 1:ntrials 26 27 nthreads_and_chunk = threads {trial} ; 28 nthreads = nthreads_and_chunk (1) ; 29 chunk = nthreads_and_chunk (2) ; 30 nthreads_set (nthreads, chunk) ; 31 32 if (nargin == 0) 33 f = fopen ('log.txt', 'a') ; 34 fprintf (f, '\n----------------------------------------------') ; 35 if (debug) 36 fprintf (f, ' [debug]') ; 37 end 38 if (compact) 39 fprintf (f, ' [compact]') ; 40 end 41 if (malloc) 42 fprintf (f, ' [malloc]') ; 43 end 44 if (covered) 45 fprintf (f, ' [cover]') ; 46 end 47 fprintf (f, '\n') ; 48 fclose (f) ; 49 return 50 end 51 52 fprintf ('\n======== test: %-10s ', testscript) ; 53 54 if (debug) 55 fprintf (' [debug]') ; 56 end 57 if (compact) 58 fprintf (' [compact]') ; 59 end 60 if (malloc) 61 fprintf (' [malloc]') ; 62 end 63 if (covered) 64 fprintf (' [cover]') ; 65 end 66 fprintf (' [nthreads: %d chunk: %g]', nthreads, chunk) ; 67 fprintf ('\n') ; 68 69 t1 = tic ; 70 runtest (testscript) 71 t = toc (t1) ; 72 73 f = fopen ('log.txt', 'a') ; 74 75 s = datestr (now) ; 76 77 % trim the year from the date 78 s = s ([1:6 12:end]) ; 79 80 fprintf ( '%s %-10s %7.1f sec ', s, testscript, t) ; 81 fprintf (f, '%s %-10s %7.1f sec ', s, testscript, t) ; 82 83 if (~isempty (strfind (pwd, 'Tcov'))) 84 global GraphBLAS_debug GraphBLAS_grbcov 85 save grbstat GraphBLAS_debug GraphBLAS_grbcov testscript 86 if (isempty (GraphBLAS_debug)) 87 GraphBLAS_debug = false ; 88 end 89 if (~isempty (GraphBLAS_grbcov)) 90 c = sum (GraphBLAS_grbcov > 0) ; 91 n = length (GraphBLAS_grbcov) ; 92 if (c == n) 93 fprintf ( '%5d: all %5d full 100%% %8.2f/sec', ... 94 c - clast, n, (c-clast) / t) ; 95 fprintf (f, '%5d: all %5d full 100%% %8.2f/sec', ... 96 c - clast, n, (c-clast) / t) ; 97 else 98 fprintf ( '%5d: %5d of %5d %5.1f%% %8.2f/sec', ... 99 c - clast, c, n, 100 * (c/n), (c-clast) / t) ; 100 fprintf (f, '%5d: %5d of %5d %5.1f%% %8.2f/sec', ... 101 c - clast, c, n, 100 * (c/n), (c-clast) / t) ; 102 end 103 if (debug) 104 fprintf (' [debug]') ; 105 end 106 if (compact) 107 fprintf (' [compact]') ; 108 end 109 if (malloc) 110 fprintf (' [malloc]') ; 111 end 112 if (covered) 113 fprintf (' [cover]') ; 114 end 115 end 116 end 117 118 fprintf ( '\n') ; 119 fprintf (f, '\n') ; 120 fclose (f) ; 121end 122