2016-09-26 65 views
0

我试图来衡量的执行时间为我在Visual Studio中的G ++ 4.2.2纳秒库#inlcude没有被编译器识别程序。我不允许编译我的程序在任何其他的编译器代替G ++ 4.2.2测量程序执行时间

有,我可以用它来衡量我在纳秒节目的开始时间和结束时间的任何其他选项。

这是我在做什么

int main(){

auto start= chrono::high_resolution_clock::now();

.....my program..... 

auto end= chrono::high_resolution_clock::now(); 
cout<<chrono::duration_cast<chrono::nanoseconds>(end - start).count(); 
return 0;} 

回答

0

计时库只能在开始C++ 11。您的编译器可能太旧以至于无法使用chrono。这个链接似乎表明,g ++ 4.3是g ++的最早版本,可以包含任何C++ 11功能。

https://gcc.gnu.org/projects/cxx-status.html#cxx11

你应该看看升压。它很可能有你可以使用的东西(即boost :: posix_time :: nanoseconds)。

http://www.boost.org/

http://www.boost.org/doc/libs/1_61_0/doc/html/date_time/posix_time.html#date_time.posix_time.time_duration