目前有不少商业软件可以完成类似的测试,比如Intel VTune,AMD CodeAnalyst等等。VS2005的Professional版本中也有相应的Profiling功能。不过,对于轻量级的代码优化而言,杀鸡未必要用牛刀。
首先,对于简单的计时需求,可以使用boost的timer类,它内部使用clock函数。如果觉得精度仍然不够的话,可以使用下面的CTimingLight类
#include <windows.h>
enum TimerType {e_TimerType_Accurate};
template<TimerType Type>
struct TimerTimeFormat {};
template<>
struct TimerTimeFormat<e_TimerType_Accurate> {
typedef LARGE_INTEGER TimeFormat;
TimeFormat StartTime;
const double Frequency;
TimerTimeFormat():Frequency(GetFrequency().LowPart) {}
void SetS
347



被折叠的 条评论
为什么被折叠?



