Navigation

Operators and Keywords

Function List:

C++ API

speed.m File Reference


Functions

endif if (nargin< 2||isempty(__init)) __init
 if (isscalar(__max_n)) __min_n
 assert (__max_n > __min_n)
 elseif (length(__max_n)==2) __min_n
 assert (__min_n >=1)
 assert (__test_n >=1)
 disp (cstrcat("testing ", __f1,"\ninit: ", __init))
 eval (cstrcat(__init,";"))
 if (!isempty(__f2)) eval(cstrcat(__f2
endif eval (cstrcat(__f1,";"))
 printf ("n%i = %i ", k, n)
 fflush (stdout)
 eval (cstrcat("__t = time();", __f1,"; __v1=ans; __t = time()-__t;"))
 eval (cstrcat("__t3 = time();", __f1,"; __t3 = time()-__t3;"))
endif __tnew (k)
 eval (cstrcat("__t3 = time();", __f2,"; __t3 = time()-__t3;"))
endif __torig (k)
 if (!isinf(__tol)) assert(__v1
 __test_n (zidx)
 __tnew (zidx)
 __torig (zidx)
 if (nargout > 0) __order.p
 if (doplot) figure
endif if (doplot &&!isempty(__f2)) subplot(1
endif semilogx (__test_n, __torig./__tnew, cstrcat("-*r;", strrep(__f1,";","."),"/", strrep(__f2,";","."),";"), __test_n, __tnew./__torig, cstrcat("-*g;", strrep(__f2,";","."),"/", strrep(__f1,";","."),";"))
 xlabel ("test length")
 title (__f1)
 ylabel ("speedup ratio")
 subplot (1, 2, 2)
 loglog (__test_n, __tnew *1000, cstrcat("*-g;", strrep(__f1,";","."),";"), __test_n, __torig *1000, cstrcat("*-r;", strrep(__f2,";","."),";"))
 ylabel ("best execution time (ms)")
 title (cstrcat("init: ", __init))
 elseif (doplot) loglog(__test_n
id g ()
 title (cstrcat(__f1," init: ", __init))
 loglog (__test_n(tailidx), exp(v)*1000, sprintf("b;%s;", order))
 if (log10(dt) >=-0.5) time
 elseif (log10(dt) >=-3.5) time
 elseif (log10(dt) >=-6.5) time
endif printf ("\nFor %s:\n", __f1)
 printf (" asymptotic power: %s\n", order)
 printf (" approximate time per operation: %s\n", time)
endif endfunction!demo if!function x ([1:10]+i *10)
!try !if (prefer_column_vectors)
endfor!endfunction !disp ("-----------------------")
 !disp ("Preallocated vector test.\nThis takes a little while...")
 !speed ('build(n)', '', 1000, 'build_orig(n)')
!clear build build_orig !disp ("Note how much faster it is to pre-allocate a vector.")
 !disp ("Notice the peak speedup ratio.")
 !disp ("Vectorized test. This takes a little while...")
 !disp ("This time, the for loop is done away with entirely.")
 !disp ("Notice how much bigger the speedup is then in example 1.")

Variables

 function [__order, __test_n, __tnew, __torig]
endif __numtests = 15
 __test_n = logspace (0, log10 (__max_n), __numtests)
 __max_n = __max_n(2)
 __torig = __tnew = zeros (size (__test_n))
 n = 1
 k = 0
 __f1
 __t2 = time()-__t2
 __t = min ([__t, __t2, __t3])
 __f2
 __v2 = ans
 __tol
else zidx = (__tnew < 100*eps)
endif tailidx = ceil(length(__test_n)/2):length(__test_n)
 p = polyfit (log (__test_n(tailidx)), log (__tnew(tailidx)), 1)
__order a = exp (p(2))
endif doplot = (nargout == 0)
 ratio = mean (__torig ./ __tnew)
execution time = sprintf ("%g ns", dt*1e9)
 v = polyval (p, log (__test_n(tailidx)))
 dt = exp (p(2))
endif endfunction!demo if!function x
endif!catch!end!for i = 0:n-1
!type build_orig
!type build
 !x = idx(:,ones(1,n))

Function Documentation

!disp ( "Notice how much bigger the speedup is then in example 1."   ) 

!disp ( "This   time,
the for loop is done away with entirely."   
)

!disp ( "Vectorized test. This takes a little while..."   ) 

!disp ( "Notice the peak speedup ratio."   ) 

! clear build build_orig !disp ( "Note how much faster it is to pre-allocate a vector."   ) 

!disp ( "Preallocated vector test.\nThis takes a little while..."   ) 

endfor ! endfunction !disp ( "-----------------------"   ) 

! try !if ( prefer_column_vectors   ) 

!speed ( 'build(n)'  ,
''  ,
1000  ,
'build_orig(n)'   
)

__test_n ( zidx   ) 

__tnew ( zidx   ) 

endif __tnew ( k   ) 

__torig ( zidx   ) 

endif __torig ( k   ) 

assert ( __test_n >=  1  ) 

assert ( __min_n >=  1  ) 

assert ( __max_n  ,
__min_n   
)

disp ( cstrcat("testing ", __f1,"\ninit: ", __init)   ) 

elseif ( log10(dt) >=-6.  5  ) 

elseif ( log10(dt) >=-3.  5  ) 

elseif ( doplot   ) 

elseif ( length(__max_n = =2  ) 

eval ( cstrcat("__t3 = time();", __f2,"; __t3 = time()-__t3;")   ) 

eval ( cstrcat("__t3 = time();", __f1,"; __t3 = time()-__t3;")   ) 

eval ( cstrcat("__t = time();", __f1,"; __v1=ans; __t = time()-__t;")   ) 

endif eval ( cstrcat(__f1,";")   ) 

eval ( cstrcat(__init,";")   ) 

fflush ( stdout   ) 

id g (  )  [virtual]

if ( log10(dt) >=-0.  5  ) 

endif if ( doplot &&!  isempty__f2  ) 

if ( doplot   ) 

if ( nargout  ,
 
)

if ( isinf__tol  ) 

if ( isempty__f2  ) 

if ( isscalar(__max_n  ) 

endif if (  ) 

loglog ( __test_n(tailidx ,
exp(v)*  1000,
sprintf("b;%s;", order)   
)

loglog ( __test_n  ,
__tnew *  1000,
cstrcat("*-g;", strrep(__f1,";","."),";")  ,
__test_n  ,
__torig *  1000,
cstrcat("*-r;", strrep(__f2,";","."),";")   
)

printf ( " approximate time per operation: %s\n"  ,
time   
)

printf ( " asymptotic power: %s\n"  ,
order   
)

endif printf ( "\nFor %s:\n"  ,
__f1   
)

printf (  ) 

endif semilogx ( __test_n  ,
__torig./  __tnew,
cstrcat("-*r;", strrep(__f1,";","."),"/", strrep(__f2,";","."),";")  ,
__test_n  ,
__tnew./  __torig,
cstrcat("-*g;", strrep(__f2,";","."),"/", strrep(__f1,";","."),";")   
)

subplot ( ,
,
 
)

title ( cstrcat(__f1," init: ", __init)   ) 

title ( cstrcat("init: ", __init)   ) 

title ( __f1   ) 

endif endfunction !demo if ! function x ( [1:10] +i *  10  ) 

Type Constraints

xlabel ( "test length"   ) 

ylabel ( "best execution time (ms)"   ) 

ylabel ( "speedup ratio  ) 


Variable Documentation

!x = idx(:,ones(1,n))

__t = min ([__t, __t2, __t3])

__t2 = time()-__t2

endif __test_n = logspace (0, log10 (__max_n), __numtests)

__torig = __tnew = zeros (size (__test_n))

__v2 = ans

__order a = exp (p(2))

endif doplot = (nargout == 0)

dt = exp (p(2))

function[__order, __test_n, __tnew, __torig]

Initial value:

 speed (__f1, __init, __max_n, __f2, __tol)

  if (nargin < 1 || nargin > 6)
    print_usage ()

endif ! catch ! end ! for i = 0:n-1

for k = 0

n = 1

p = polyfit (log (__test_n(tailidx)), log (__tnew(tailidx)), 1)

ratio = mean (__torig ./ __tnew)

endif tailidx = ceil(length(__test_n)/2):length(__test_n)

else time = sprintf ("%g ns", dt*1e9)

v = polyval (p, log (__test_n(tailidx)))

! try x

Initial value:

 build_orig(n)
%!    ## extend the target vector on the fly
%!    for i=0:n-1

else zidx = (__tnew < 100*eps)