Skip to content
Permalink
Browse files

sim: getters for timings

  • Loading branch information...
FreyJo committed Oct 5, 2019
1 parent 41725a0 commit 8d1b844f5bb26dd82afff65c7161dc601f50beec
Showing with 39 additions and 14 deletions.
  1. +15 −0 acados/sim/sim_common.c
  2. +24 −14 test/sim/sim_test_ode.cpp
@@ -391,6 +391,21 @@ int sim_out_get_(void *config_, void *dims_, sim_out *out, const char *field, vo
for (int ii=0; ii < nz*(nu+nx); ii++)
S_algebraic[ii] = out->S_algebraic[ii];
}
else if (!strcmp(field, "CPUtime") || !strcmp(field, "time_tot"))
{
double *time = value;
*time = out->info->CPUtime;
}
else if (!strcmp(field, "ADtime") || !strcmp(field, "time_ad"))
{
double *time = value;
*time = out->info->ADtime;
}
else if (!strcmp(field, "LAtime") || !strcmp(field, "time_la"))
{
double *time = value;
*time = out->info->LAtime;
}
else
{
printf("sim_out_get_: field %s not supported \n", field);
@@ -333,13 +333,13 @@ TEST_CASE("wt_nx3_example", "[integrators]")
// d_print_exp_mat(nx, NF, &S_forw_ref_sol[0], 1);


free(config);
free(dims);
free(opts);
sim_config_destroy(config);
sim_dims_destroy(dims);
sim_opts_destroy(opts);

free(in);
free(out);
free(sim_solver);
sim_in_destroy(in);
sim_out_destroy(out);
sim_solver_destroy(sim_solver);

for (std::string solver : solvers)
{
@@ -564,14 +564,24 @@ TEST_CASE("wt_nx3_example", "[integrators]")
REQUIRE(max_error_adj <= tol);
}


free(config);
free(dims);
free(opts);

free(in);
free(out);
free(sim_solver);
// test getters
double time_tot, time_ad, time_la;
sim_out_get(config, dims, out, "CPUtime", &time_tot);
REQUIRE(std::isnan(time_tot) == 0);
sim_out_get(config, dims, out, "ADtime", &time_ad);
REQUIRE(std::isnan(time_ad) == 0);
sim_out_get(config, dims, out, "LAtime", &time_la);
REQUIRE(std::isnan(time_la) == 0);
REQUIRE( time_tot >= time_ad + time_la );
// printf("time_tot %f, time_ad %f, time_la %f", time_tot, time_ad, time_la);

sim_config_destroy(config);
sim_dims_destroy(dims);
sim_opts_destroy(opts);

sim_in_destroy(in);
sim_out_destroy(out);
sim_solver_destroy(sim_solver);
} // end for num_steps
} // end section
} // END FOR SOLVERS

0 comments on commit 8d1b844

Please sign in to comment.
You can’t perform that action at this time.