88#define CUQDYN_CONF "../tests/data/nfkb_cuqdyn_config.xml"
99
1010void bench_transform_states ();
11+ void bench_transform_states_2 ();
1112
1213int main ()
1314{
1415 CuqDynContext context = init_cuqdyn_context_from_file (CUQDYN_CONF );
1516 CuqdynConf * conf = get_cuqdyn_conf (context );
1617
1718 BenchFunc funcs [] = {
18- bench_transform_states
19+ bench_transform_states ,
20+ bench_transform_states_2
1921 };
2022
2123 BenchOptions * options = create_bench_options ("Transform States" , funcs , sizeof (funcs ) / sizeof (funcs [0 ]));
@@ -25,49 +27,43 @@ int main()
2527 return 0 ;
2628}
2729
30+ #define STATES_ROWS 1000
31+ #define STATES_COLS 16
32+
2833void bench_transform_states ()
2934{
30- #define STATES_ROWS 28
31- #define STATES_COLS 16
32-
33- sunrealtype states_values [STATES_COLS ][STATES_ROWS ] = {
34- 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
35- 1 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ,
36- 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ,
37- 3 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ,
38- 4 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ,
39- 5 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ,
40- 6 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ,
41- 7 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 ,
42- 8 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 , 2 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, 2 , 2 ,
58- };
35+ sunrealtype states_values [STATES_COLS ][STATES_ROWS ] = { 0 };
5936
6037 SUNMatrix states = NewDenseMatrix (STATES_ROWS , STATES_COLS );
6138
62- for (int i = 0 ; i < STATES_ROWS ; ++ i )
39+ for (int i = 0 ; i < STATES_ROWS ; ++ i )
6340 {
64- for (int j = 0 ; j < STATES_COLS ; ++ j )
41+ for (int j = 0 ; j < STATES_COLS ; ++ j )
6542 {
66- SM_ELEMENT_D (states , i , j ) = states_values [j ][i ];
43+ SM_ELEMENT_D (states , i , j ) = states_values [j ][i ];
6744 }
6845 }
6946
7047 SUNMatrix transformed_states = transform_states (states );
7148
7249 SUNMatDestroy (transformed_states );
7350}
51+
52+ void bench_transform_states_2 ()
53+ {
54+ sunrealtype states_values [STATES_ROWS ][STATES_COLS ] = { 0 };
55+
56+ SUNMatrix states = NewDenseMatrix (STATES_COLS , STATES_ROWS );
57+
58+ for (int i = 0 ; i < STATES_ROWS ; ++ i )
59+ {
60+ for (int j = 0 ; j < STATES_COLS ; ++ j )
61+ {
62+ SM_ELEMENT_D (states , j , i ) = states_values [i ][j ];
63+ }
64+ }
65+
66+ SUNMatrix transformed_states = transform_states_2 (states );
67+
68+ SUNMatDestroy (transformed_states );
69+ }
0 commit comments