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


C++ Stopwatch::ElapsedTime方法代码示例

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


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

示例1: main

int main()
{
    Stopwatch stopwatch;
    HANDLE hTimer = NULL;

    // Create an unnamed waitable timer.
    hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
    if (NULL == hTimer) {
        printf("CreateWaitableTimer failed (%d)\n", GetLastError());
        return 1;
    }

    // With Sleep
    stopwatch.Start();
    DoWait(hTimer, 1000);
    printf("Wait 1000ms, Elapsed time : %d\n", stopwatch.ElapsedTime());

    // With Sleep
    stopwatch.Start();
    DoWait(hTimer, 1234);
    Sleep(100);
    printf("Wait 1234ms with Sleep(100), Elapsed time : %d\n", stopwatch.ElapsedTime());

    return 0;
}
开发者ID:zealic,项目名称:zealic-learn,代码行数:25,代码来源:WaitableTimer.cpp

示例2: main


//.........这里部分代码省略.........

    timer.Restart();

    if ( conf%n_chkpt==0 ) {

      std::cout << "\t";
      ss.str(std::string());
      ss << cfg_file_stem << "-" << conf << ".bin";
      if (!latticeX.Read(ss.str()) ) {
        std::cout << "Failed to find lattice : " << std::endl;
        std::cout <<  ss.str() << std::endl;
        exit(EXIT_FAILURE);
      };

      std::cout << "\t";
      std::cout << "Computing observables..." << std::endl;

      monster.Initialize(latticeX);
      for (int m=0; m<n_plaq/2; ++m)
      for (int n=0; n<n_plaq/2; ++n) {
        plaq[m][n].push_back( 1.0-monster.MeanPlaquette(m+1,n+1) );
      }

      if (retherm_sweeps>0) {

        std::cout << "\t";
        std::cout << "Refining lattice..." << std::endl;
        if ( !InterpolatedTwoCellBoundaryRefine(latticeX, lattice) ) {
          std::cout << "Failed to refine lattice!" << std::endl;
          exit(EXIT_FAILURE);
        }

        for(int cool_sweeps=0; cool_sweeps<50; ++cool_sweeps) {
          lattice.CoolUpdate(Subsets::two_cell_bulk_checker_board);
        }

        std::cout << "\t";
        std::cout << "Performing rethermalization sweeps and computing observables..." << std::endl;
        for (int h=0; h<retherm_sweeps; ++h) {
          monster.Initialize(lattice);
          for (int m=0; m<n_plaq; ++m)
          for (int n=0; n<n_plaq; ++n) {
            plaqs[m][n][h].push_back( 1.0-monster.MeanPlaquette(m+1,n+1) );
          }
          lattice.HeatBathUpdate(beta);
        }
      }
    }
 
    std::cout << "Total time for config " << conf << " is : " << timer.ElapsedTime() << std::endl;
    ++conf;

  } while (conf < n_conf);


//// Write observables to a file ////

  for (int m=0; m<n_plaq; ++m)
  for (int n=0; n<n_plaq; ++n) {
    ss.str(std::string());
    ss << plaq_file_stem << "-" << m+1 << "_" << n+1 << ".dat";
    std::cout << "Writing observables to file : ";
    std::cout << ss.str()  << std::endl;
    file.open(ss.str().c_str());
    file << setprecision(15);
    for(int j=0; j<plaq[m][n].size(); ++j) {
      file << plaq[m][n][j] << std::endl;
    }
    file.close();
  }

  for (int m=0; m<n_plaq; ++m)
  for (int n=0; n<n_plaq; ++n)
  for (int h=0; h<retherm_sweeps; ++h) {
    ss.str(std::string());
    ss << plaq_file_stem << "-" << m+1 << "_" << n+1 << "-" << h << ".dat";
    std::cout << "Writing observables to file : ";
    std::cout << ss.str()  << std::endl;
    file.open(ss.str().c_str());
    file << setprecision(15);
    for(int j=0; j<plaqs[m][n][h].size(); ++j) {
      file << plaqs[m][n][h][j] << std::endl;
    }
    file.close();
  }

//// DONE! ////

  for (int i=0; i<n_plaq; ++i) {
    for (int j=0; j<n_plaq; ++j) { delete [] plaqs[i][j]; }
    delete [] plaq[i];
    delete [] plaqs[i];
  }
  delete [] plaq;
  delete [] plaqs;

  cout << "Congratulations on a job... done!" << endl;
  exit(EXIT_SUCCESS);

}
开发者ID:mgendres,项目名称:multilevel_su2,代码行数:101,代码来源:v2.C


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