[Contents] [TitleIndex] [WordIndex

1. Benchmarks

1.1. Launcher

1.1.1. All bench

Launch Scilab and type :

bench_run()

It will run all the tests and provide this kind of output :

-->bench_run()
             Boucle For .......................................        0.18 µs [ 1000000 x]
   001/046 - [STRING_V2] bench_ascii_1 ........................      195.82 µs [   10000 x]
   002/046 - [STRING_V2] bench_ascii_2 ........................       13.82 µs [   10000 x]
   003/046 - [STRING_V2] bench_ascii_3 ........................      510.82 µs [   10000 x]
   004/046 - [STRING_V2] bench_ascii_4 ........................      775.82 µs [   10000 x]
   005/046 - [STRING_V2] bench_code2str .......................        7.82 µs [   10000 x]
   006/046 - [STRING_V2] bench_convstr ........................        7.82 µs [   10000 x]
   [...]

1.1.1.1. Test only one module

-->bench_run('time')
             Boucle For .......................................        0.18 µs [ 1000000 x]
   001/010 - [time] bench_calendar ............................      188.82 µs [   10000 x]
   002/010 - [time] bench_clock ...............................      897.82 µs [   10000 x]
   003/010 - [time] bench_datenum_1 ...........................      518.82 µs [   10000 x]
   004/010 - [time] bench_datenum_2 ...........................      438.82 µs [   10000 x]
   005/010 - [time] bench_datenum_3 ...........................      472.82 µs [   10000 x]
   006/010 - [time] bench_datevec .............................      287.82 µs [   10000 x]
   007/010 - [time] bench_eomday ..............................      245.82 µs [   10000 x]
   008/010 - [time] bench_getdate .............................       56.82 µs [   10000 x]
   009/010 - [time] bench_now .................................      520.82 µs [   10000 x]
   010/010 - [time] bench_weekday .............................      459.82 µs [   10000 x]

1.1.1.2. Test only one bench

-->bench_run('time','bench_calendar')
             Boucle For .......................................        0.19 µs [ 1000000 x]
   001/001 - [time] bench_calendar ............................      184.81 µs [   10000 x]

1.1.1.3. Change the number of loops by default

The number of loops by default is 10000. You can adjust it with the "nb_run=xxx" option :

-->bench_run('time','bench_calendar','nb_run=100000')
             Boucle For .......................................        0.19 µs [ 1000000 x]
   001/001 - [time] bench_calendar ............................      184.96 µs [  100000 x]

1.1.1.4. To list available benchmarks

-->bench_run([],[],'list')

   001 - [STRING_V2] bench_ascii_1
   002 - [STRING_V2] bench_ascii_2
   003 - [STRING_V2] bench_ascii_3
   004 - [STRING_V2] bench_ascii_4
   005 - [STRING_V2] bench_code2str
   006 - [STRING_V2] bench_convstr
   007 - [STRING_V2] bench_emptrystr
   008 - [STRING_V2] bench_grep
   009 - [STRING_V2] bench_length
   010 - [STRING_V2] bench_part
   011 - [STRING_V2] bench_str2code
   012 - [STRING_V2] bench_strcat
   013 - [STRING_V2] bench_strindex
   014 - [STRING_V2] bench_string
   015 - [STRING_V2] bench_stripblanks
   016 - [STRING_V2] bench_strsplit
   017 - [STRING_V2] bench_strsubst
   018 - [STRING_V2] bench_tokens
   019 - [core] bench_for
   020 - [elementary_functions] bench_ceil
   021 - [elementary_functions] bench_ones
   022 - [elementary_functions] bench_sort
   023 - [elementary_functions] bench_sqrt
   024 - [linear_algebra] bench_chol
   025 - [linear_algebra] bench_det
   026 - [linear_algebra] bench_escoufier
   027 - [linear_algebra] bench_inv
   028 - [linear_algebra] bench_matrix_1
   029 - [linear_algebra] bench_matrix_2
   030 - [linear_algebra] bench_matrix_3
   031 - [linear_algebra] bench_matrix_4
   032 - [linear_algebra] bench_spec
   033 - [linear_algebra] bench_sqroot
   034 - [linear_algebra] bench_sva
   035 - [linear_algebra] bench_svd_1
   036 - [linear_algebra] bench_svd_2
   037 - [time] bench_calendar
   038 - [time] bench_clock
   039 - [time] bench_datenum_1
   040 - [time] bench_datenum_2
   041 - [time] bench_datenum_3
   042 - [time] bench_datevec
   043 - [time] bench_eomday
   044 - [time] bench_getdate
   045 - [time] bench_now
   046 - [time] bench_weekday

1.2. How to add a benchmarks

1.2.1. Benchmarks location and naming rule

Benchmarks are located in the SCI/<module>/tests/benchmarks directory and are all named bench_<testname>.tst

1.2.2. Code convention

2 tags are needed in a benchmark script to delimit the main loop

You can force the number of loops with the following tag (default is 10000) :

1.2.2.1. example

// <-- BENCH NB RUN : 100 -->
a = 0;
b = 0;

a = rand(400, 400,'n');

// <-- BENCH START -->
b = inv(a);
// <-- BENCH END -->

Then, the bench_run() function transform this script into :

a = 0;
b = 0;
a = rand(400, 400,'n');
nb_run = 100;
timer();
for i = 1:nb_run
b = inv(a);
end
timing = timer();
returned_time = timing * 1000000 / nb_run;

2022-09-08 09:27