Benchmarks
Contents
Launcher
All bench
Launch Scilab and type :
1 bench_run()
It will run all the tests and provide this kind of output :
1 -->bench_run()
2 Boucle For ....................................... 0.18 µs [ 1000000 x]
3 001/046 - [STRING_V2] bench_ascii_1 ........................ 195.82 µs [ 10000 x]
4 002/046 - [STRING_V2] bench_ascii_2 ........................ 13.82 µs [ 10000 x]
5 003/046 - [STRING_V2] bench_ascii_3 ........................ 510.82 µs [ 10000 x]
6 004/046 - [STRING_V2] bench_ascii_4 ........................ 775.82 µs [ 10000 x]
7 005/046 - [STRING_V2] bench_code2str ....................... 7.82 µs [ 10000 x]
8 006/046 - [STRING_V2] bench_convstr ........................ 7.82 µs [ 10000 x]
9 [...]
Test only one module
1 -->bench_run('time')
2 Boucle For ....................................... 0.18 µs [ 1000000 x]
3 001/010 - [time] bench_calendar ............................ 188.82 µs [ 10000 x]
4 002/010 - [time] bench_clock ............................... 897.82 µs [ 10000 x]
5 003/010 - [time] bench_datenum_1 ........................... 518.82 µs [ 10000 x]
6 004/010 - [time] bench_datenum_2 ........................... 438.82 µs [ 10000 x]
7 005/010 - [time] bench_datenum_3 ........................... 472.82 µs [ 10000 x]
8 006/010 - [time] bench_datevec ............................. 287.82 µs [ 10000 x]
9 007/010 - [time] bench_eomday .............................. 245.82 µs [ 10000 x]
10 008/010 - [time] bench_getdate ............................. 56.82 µs [ 10000 x]
11 009/010 - [time] bench_now ................................. 520.82 µs [ 10000 x]
12 010/010 - [time] bench_weekday ............................. 459.82 µs [ 10000 x]
Test only one bench
1 -->bench_run('time','bench_calendar')
2 Boucle For ....................................... 0.19 µs [ 1000000 x]
3 001/001 - [time] bench_calendar ............................ 184.81 µs [ 10000 x]
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 :
1 -->bench_run('time','bench_calendar','nb_run=100000')
2 Boucle For ....................................... 0.19 µs [ 1000000 x]
3 001/001 - [time] bench_calendar ............................ 184.96 µs [ 100000 x]
To list available benchmarks
1 -->bench_run([],[],'list')
2
3 001 - [STRING_V2] bench_ascii_1
4 002 - [STRING_V2] bench_ascii_2
5 003 - [STRING_V2] bench_ascii_3
6 004 - [STRING_V2] bench_ascii_4
7 005 - [STRING_V2] bench_code2str
8 006 - [STRING_V2] bench_convstr
9 007 - [STRING_V2] bench_emptrystr
10 008 - [STRING_V2] bench_grep
11 009 - [STRING_V2] bench_length
12 010 - [STRING_V2] bench_part
13 011 - [STRING_V2] bench_str2code
14 012 - [STRING_V2] bench_strcat
15 013 - [STRING_V2] bench_strindex
16 014 - [STRING_V2] bench_string
17 015 - [STRING_V2] bench_stripblanks
18 016 - [STRING_V2] bench_strsplit
19 017 - [STRING_V2] bench_strsubst
20 018 - [STRING_V2] bench_tokens
21 019 - [core] bench_for
22 020 - [elementary_functions] bench_ceil
23 021 - [elementary_functions] bench_ones
24 022 - [elementary_functions] bench_sort
25 023 - [elementary_functions] bench_sqrt
26 024 - [linear_algebra] bench_chol
27 025 - [linear_algebra] bench_det
28 026 - [linear_algebra] bench_escoufier
29 027 - [linear_algebra] bench_inv
30 028 - [linear_algebra] bench_matrix_1
31 029 - [linear_algebra] bench_matrix_2
32 030 - [linear_algebra] bench_matrix_3
33 031 - [linear_algebra] bench_matrix_4
34 032 - [linear_algebra] bench_spec
35 033 - [linear_algebra] bench_sqroot
36 034 - [linear_algebra] bench_sva
37 035 - [linear_algebra] bench_svd_1
38 036 - [linear_algebra] bench_svd_2
39 037 - [time] bench_calendar
40 038 - [time] bench_clock
41 039 - [time] bench_datenum_1
42 040 - [time] bench_datenum_2
43 041 - [time] bench_datenum_3
44 042 - [time] bench_datevec
45 043 - [time] bench_eomday
46 044 - [time] bench_getdate
47 045 - [time] bench_now
48 046 - [time] bench_weekday
How to add a benchmarks
Benchmarks location and naming rule
Benchmarks are located in the SCI/<module>/tests/benchmarks directory and are all named bench_<testname>.tst
Code convention
2 tags are needed in a benchmark script to delimit the main loop
<-- BENCH START -->
<-- BENCH START -->
You can force the number of loops with the following tag (default is 10000) :
<-- BENCH NB RUN : 100 -->
example
1 // <-- BENCH NB RUN : 100 -->
2 a = 0;
3 b = 0;
4
5 a = rand(400, 400,'n');
6
7 // <-- BENCH START -->
8 b = inv(a);
9 // <-- BENCH END -->
Then, the bench_run() function transform this script into :
1 a = 0;
2 b = 0;
3 a = rand(400, 400,'n');
4 nb_run = 100;
5 timer();
6 for i = 1:nb_run
7 b = inv(a);
8 end
9 timing = timer();
10 returned_time = timing * 1000000 / nb_run;
