C++库研究笔记[1] Profile->程序执行时间统计

来源:互联网 发布:化学查询软件下载 编辑:程序博客网 时间:2024/06/16 08:16

研究nvidia 的cusp 库,可见到这样的代码:

template <typename Array1,                                                                       380           typename Array2,                                                                     381       typename ScalarType>                                                                           382 void axpy(const Array1& x,                                                                            383           const Array2& y,                                                                 384           ScalarType alpha)                                                             385 {                                                                                               386     CUSP_PROFILE_SCOPED();                                                                       387     detail::assert_same_dimensions(x, y);                                                           388     cusp::blas::detail::axpy(x.begin(), x.end(), y.begin(), alpha);                                389 }   
这一行
386     CUSP_PROFILE_SCOPED();                                                                       
即为时间统计

参考:

主要:

High Performance C++ Profiling   :http://floodyberry.wordpress.com/2009/10/07/high-performance-cplusplus-profiling/

clock() 函数相当的严重不准确

Resolution Problems inclock()

http://www.guyrutenberg.com/2007/09/10/resolution-problems-in-clock/

Profiling Code Usingclock_gettime

http://www.guyrutenberg.com/2007/09/22/profiling-code-using-clock_gettime/

原创粉丝点击