当前位置: 首页>>代码示例>>C++>>正文


C++ Benchmark::finalize方法代码示例

本文整理汇总了C++中Benchmark::finalize方法的典型用法代码示例。如果您正苦于以下问题:C++ Benchmark::finalize方法的具体用法?C++ Benchmark::finalize怎么用?C++ Benchmark::finalize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Benchmark的用法示例。


在下文中一共展示了Benchmark::finalize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(const int argc, const char* argv[])
{
    InputArgs input_args;
    if (!read_cli_arguments(input_args, argc, argv))
    {
        std::cerr << "usage: " << argv[0] << " CONF OUTPUT NSTEPS\n"
                  << "\n"
                  << "where\n"
                  << "  CONF is an input configuration in .gro format\n"
                  << "  OUTPUT is the final output configuration\n"
                  << "  NSTEPS is the number of steps to run\n";
        return 1;
    }

    std::cout << "Input arguments: "
              << "conf = " << input_args.input_conf
              << ", output = " << input_args.output_conf
              << ", num_steps = " << input_args.num_steps
              << "\n\n";

    const auto& ff = ArgonFF;

    std::cerr << "Reading configuration ... ";
    auto system = read_conf_from_grofile(input_args.input_conf, ff.sigma);
    std::cerr << "done.\n";

    std::cerr << "Setting up system ... ";
    create_cell_lists(system, ff.rcut);
    gen_system_velocities(system, 3.0);
    std::cerr << "done.\n";

    std::cerr << '\n';
    describe_system_config(system, ff);
    std::cerr << '\n';

    Benchmark benchmark;
    Energetics energy;

    std::cerr << "Simulating " << input_args.num_steps << " steps:\n";

    // [WIP] trajectory output
    benchmark.start_traj_output_update();
    std::string fntraj { "traj.gro" };
    {
        std::ofstream reset { fntraj, std::ios::out | std::ios::trunc };
    }
    benchmark.stop_traj_output_update();

    for (unsigned step = 0; step < input_args.num_steps; ++step)
    {
        if ((step % 10) == 0)
        {
            std::cerr << "\rstep " << step;
        }

        run_velocity_verlet(system, benchmark, ff, DefaultOpts);

        benchmark.start_energy_calc_update();
        if (step != 0 && (step % DefaultOpts.energy_calc) == 0)
        {
            calculate_system_energetics(energy, system, ff);
        }
        benchmark.stop_energy_calc_update();

        // [WIP] trajectory output
        benchmark.start_traj_output_update();
        if (step != 0 && (step % 20 == 0))
        {
            write_conf_to_grofile(system, fntraj, ff.sigma, OutputMode::Append);
        }
        benchmark.stop_traj_output_update();
    }

    benchmark.finalize();

    std::cerr << "\r                                                  \r"
              << "Finished.\n\n";

    std::cerr << "Writing final system to disk as '"
        << input_args.output_conf
        << "' ... ";
    write_conf_to_grofile(system, input_args.output_conf, ff.sigma, OutputMode::Replace);
    std::cerr << "done.\n";

    std::cerr << '\n';
    print_energetics(energy, ff);
    std::cerr << '\n';
    print_benchmark(benchmark);

    auto t = std::time(nullptr);
    std::cerr << "\nFinished simulation at "
        << std::put_time(std::localtime(&t), "%c") << ".\n";

    return 0;
}
开发者ID:pjohansson,项目名称:hpc-moldyn,代码行数:95,代码来源:main.cpp


注:本文中的Benchmark::finalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。