本文整理汇总了C++中CPUTimer::elapsed_sec方法的典型用法代码示例。如果您正苦于以下问题:C++ CPUTimer::elapsed_sec方法的具体用法?C++ CPUTimer::elapsed_sec怎么用?C++ CPUTimer::elapsed_sec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPUTimer
的用法示例。
在下文中一共展示了CPUTimer::elapsed_sec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run_all_periodic_test
void run_all_periodic_test(int nx, int ny, int nz, float hx, float hy, float hz, double tol)
{
BoundaryConditionSet bc;
set_bc(bc, BC_PERIODIC, 0);
Sol_PCGPressure3DDeviceD solver;
Grid3DDeviceD rhs, coeff;
init_rhs(rhs, nx, ny, nz, hx, hy, hz, -1, false); // init to sin waves, no axis
init_coeff(coeff, nx, ny, nz, hx, hy, hz);
init_solver(solver, rhs, coeff, bc, nx, ny, nz, hx, hy, hz);
init_search_vector(solver, nx, ny, nz, false); // init to zero
double residual;
CPUTimer timer;
timer.start();
UNITTEST_ASSERT_TRUE(solver.solve(residual,tol,1000));
timer.stop();
printf("%f sec\n", timer.elapsed_sec());
UNITTEST_ASSERT_EQUAL_DOUBLE(residual, 0, tol);
}
示例2: run_resolution
void run_resolution(int res, double dt, double t1, double Ra, double Pr, bool do_diagnostic=true) {
Eqn_IncompressibleNS3DParamsD params;
Eqn_IncompressibleNS3DD eqn;
init_params(params, res, Ra, Pr);
UNITTEST_ASSERT_TRUE(eqn.set_parameters(params));
int next_frame = 1;
CPUTimer clock;
CPUTimer step_clock;
int step_count;
int start_count=0;
start_count = eqn.num_steps;
clock.start();
global_timer_clear_all();
step_count = eqn.num_steps;
step_clock.start();
set_forge_ahead(true);
for (double t = 0; t <= t1; t += dt) {
UNITTEST_ASSERT_TRUE(eqn.advance_one_step(dt));
if (do_diagnostic) {
double max_u, max_v, max_w;
eqn.get_u().reduce_maxabs(max_u);
eqn.get_v().reduce_maxabs(max_v);
eqn.get_w().reduce_maxabs(max_w); // not used in any calculations, but useful for troubleshooting
printf("> Max u = %.12f, Max v = %.12f, Max w = %.12f\n", max_u, max_v, max_w);
fflush(stdout);
if (t > next_frame * t1/100) {
char buff[1024];
sprintf(buff, "output.%04d.ppm", next_frame);
printf("%s\n", buff);
write_slice(buff, eqn.get_temperature());
next_frame++;
}
}
else {
if (t > next_frame * t1/100) {
step_clock.stop();
printf("ms/step = %f\n", step_clock.elapsed_ms() / (eqn.num_steps - step_count));
char buff[1024];
sprintf(buff, "output.%04d.ppm", next_frame);
global_counter_print();
global_counter_clear_all();
printf("%s\n", buff);
write_slice(buff, eqn.get_temperature());
next_frame++;
step_count = eqn.num_steps;
step_clock.start();
}
printf("%.4f%% done\r", t/t1 * 100);
}
}
clock.stop();
printf("Elapsed sec: %.8f\n", clock.elapsed_sec());
printf("ms/step = %f\n", clock.elapsed_ms() / (eqn.num_steps - start_count));
printf("\n............ DONE ...............\n\n");
}