计时器定时器始终显示0

时间:2013-02-24 04:49:06

标签: c++ sorting timer

所以我正在调整排序算法的计时,当我运行我的代码时,无论它总是显示0,但如果我使用断点,它在这里工作是我的代码的一部分我在使用计时器:

case 'I':{ 
  auto startTime = chrono::high_resolution_clock::now(); //start the clock
  numbers.InsertionSort();//sorts the array using insertion sort method
  auto endTime = chrono::high_resolution_clock::now();//ends the clock
  cout<<"Insertion Sort of size: "<<numbers.GetSize()<<" took: "  
      <<chrono::duration_cast<chrono::milliseconds>(endTime-startTime).count() 
      <<" Millisecond"<<endl; //ouput the result to the screen
  break;//exit
}

我尝试使用标准计时器,但它没有给我足够的精度,所以我去了计时器。我的老师希望我们以毫秒为单位输出结果。这就是我使用那个时间段的原因

0 个答案:

没有答案
相关问题