<< scibench_cholesky Benchmark Toolbox scibench_getsettings >>

Benchmark Toolbox >> Benchmark Toolbox > scibench_dynbenchfun

scibench_dynbenchfun

Benchmarks a function with increasing data size.

Calling Sequence

perftable = scibench_dynbenchfun ( fun )
perftable = scibench_dynbenchfun ( fun , verbose )
perftable = scibench_dynbenchfun ( fun , verbose , dispgraph )
perftable = scibench_dynbenchfun ( fun , verbose , dispgraph , timemin )
perftable = scibench_dynbenchfun ( fun , verbose , dispgraph , timemin , timemax )
perftable = scibench_dynbenchfun ( fun , verbose , dispgraph , timemin , timemax , nfact )
perftable = scibench_dynbenchfun ( fun , verbose , dispgraph , timemin , timemax , nfact , outfun )

Parameters

fun :

a function or a list, the function to be executed. If fun is a list, the first element is expected to be a function and the remaining elements of the list are input arguments of the function, which are appended at the end.

verbose :

a 1-by-1 matrix of booleans, set to %t to print messages during and at the end of the experiment (default verbose=%t).

dispgraph :

a 1-by-1 matrix of booleans, set to %t to create a plot (default dispgraph=%t).

timemin :

a 1-by-1 matrix of doubles, the minimum time (in seconds) to measure the mflops (default timemin=0.001). Must be positive.

timemax :

a 1-by-1 matrix of doubles, the maximum time (in seconds) to measure the mflops (default timemax=0.1). Must be larger than timemin. The experiment ends when this time is reached.

nfact :

a 1-by-1 matrix of doubles, the multiplication factor for the size n of the matrix (default nfact=1.2). Must be greater than 1. At each step of the algorithm, the size n of the matrix is updated with n = n * nfact.

outfun :

a function or a list, the output function (default is an empty output function). If outfun is a list, the first element is expected to be a function and the remaining elements of the list are input arguments of the function, which are appended at the end.

perftable :

a m-by-3 matrix of doubles, the performances.

perftable(k,1) :

size of the data for experiment #k

perftable(k,2) :

wall clock time for experiment #k

Description

This function allows to measure the performance of a function depending on an increasing parameter representing the size of the problem.

The wall clock time is measured with the tic and toc functions.

The algorithm starts with a data size size equal to n = 1. Then the data size is updated, by using n = n * nfact. The performance is measured as soon as the elapsed time is greater than timemin. The algorithm stops when the elapsed time is greater than timemax.

Any argument equal to the empty matrix [] is replaced by its default value.

The header of the function fun must be

t=fun(n)
where n represents the current data size, and t measures the time to perform the task (in seconds).

It might happen that the function requires additionnal arguments to be evaluated. In this case, we can use the following feature. The function fun can also be the list (f,a1,a2,...). In this case f, the first element in the list, must have the header:

t = f ( x , a1 , a2 , ... )
where the input arguments a1, a2, ... will be automatically be appended at the end of the calling sequence.

The output function outfun should have header

stop = outfun ( k , n , t )
where k is the simulation index, n is the size of the problem and t is the time required to perform the run. Here, stop is a boolean, which is %t if the algorithm must stop. This feature may be used in the case where the algorithm never stops, because the time never reaches the upper limit. The user may then configure a maximum number of runs, or whatever appropriate.

It might happen that the output function requires additionnal arguments to be evaluated. In this case, we can use the following feature. The output function outfun can also be a list, with header

stop = outfun ( k , n , t , a1 , a2 , ... )
In this case, the outfun variable should hold the list (f,a1,a2,...) and the input arguments a1, a2, ... will be automatically be appended at the end of the calling sequence.

In practice, the function to benchmark may create temporary variables before actually perform the computation. This pre-processing has some CPU cost which may change the measured performance significantly.

Examples

lines(0);
stacksize("max");
function t=pascalup_col(n)
// Pascal up matrix.
// Column by column version
tic()
c = eye(n,n)
c(1,:) = ones(1,n)
for i = 2:(n-1)
c(2:i,i+1) = c(1:(i-1),i)+c(2:i,i)
end
t = toc()
endfunction
scf();
perftable = scibench_dynbenchfun ( pascalup_col )
perftable = scibench_dynbenchfun ( pascalup_col , %t );
perftable = scibench_dynbenchfun ( pascalup_col , %t , %t );
perftable = scibench_dynbenchfun ( pascalup_col , %t , %t , 0.1 );
perftable = scibench_dynbenchfun ( pascalup_col , %t , %t , 0.1 , 1 );
perftable = scibench_dynbenchfun ( pascalup_col , %t , %t , 0.1 , 1 , 1.2 );

// Do not print a message
scibench_dynbenchfun ( pascalup_col , %f );

// Do not create the graph
scibench_dynbenchfun ( pascalup_col , [] , %f );

// With an additionnal argument
function t=pascalup_col2(n, alpha)
tic()
c = eye(n,n) * alpha
c(1,:) = ones(1,n)
for i = 2:(n-1)
c(2:i,i+1) = c(1:(i-1),i)+c(2:i,i)
end
t = toc()
endfunction
scibench_dynbenchfun ( list(pascalup_col2,2) );

//
// Use a callback to print the timings.
function stop=myoutfun(k, n, t)
mprintf("Run #%d, n=%d, t=%.2f\n",k,n,t)
stop = %f
endfunction
scibench_dynbenchfun ( pascalup_col , %f , %f , [] , [] , [] , myoutfun );
//
// Use a callback to print the timings.
// The callback requires additionnal arguments.
function stop=myoutfun2(k, n, t, data)
mprintf("Run #%d, n=%d, t=%.2f\n",k,n,t)
stop = %f
endfunction
scibench_dynbenchfun ( pascalup_col , %f , %f , [] , [] , [] , list(myoutfun2,2) );

// Use a callback to print the timings and stop the algorithm.
function stop=myoutfun4(k, n, t, kmax)
mprintf("Run #%d, n=%d, t=%.2f\n",k,n,t)
stop = ( k >= kmax )
endfunction
scibench_dynbenchfun ( pascalup_col , %f , %f , [] , [] , [] , list(myoutfun4,2) );

Authors

<< scibench_cholesky Benchmark Toolbox scibench_getsettings >>