timer.cpp

来自「强大的C++库」· C++ 代码 · 共 39 行

CPP
39
字号
#include <itpp/itbase.h>using namespace itpp;//These lines are needed for use of cout and endlusing std::cout;using std::endl;int main(){  //Declare the scalars used:  long i, sum, N;  //Declare tt as an instance of the timer class:  Real_Timer tt;  //Initiate the variables:  N = 1000000;  sum = 0;  //Start and reset the timer:  tt.tic();  //Do some processing  for (i=0; i<N; i++) {    sum += i;  }  // Print the elapsed time  tt.toc_print();  //Print the result of the processing:  cout << "The sum of all integers from 0 to " << N-1 << " equals " << sum << endl;  //Exit program:  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?