测试代码运行效率

#include <time.h>
#define BEGIN_COUNT(mark) __int64 __begin_count##mark;\
    QueryPerformanceCounter((LARGE_INTEGER
*)&__begin_count##mark);\

#define END_COUNT(mark) __int64 __end_count##mark;\
    QueryPerformanceCounter((LARGE_INTEGER
*)&__end_count##mark);\
    __int64 __Frequency##mark;\
    QueryPerformanceFrequency((LARGE_INTEGER
*)&__Frequency##mark);\
    
double __interval##mark;\
    __interval##mark 
= __end_count##mark - __begin_count##mark;\
    
double __begin##mark;\
    __begin##mark 
= __begin_count##mark * 1000000 /__Frequency##mark;\
    
double  __end##mark;\
    __end##mark   
=   __end_count##mark * 1000000 /__Frequency##mark;\
    
double   __usec##mark;\
    __usec##mark   
=   __interval##mark * 1000000 /__Frequency##mark;\
    ATLTRACE(
"From begin %10.2lf\n to end %10.2lf,\nCPU elapsed time %10.2lf microseconds",__begin##mark,__end##mark,__usec##mark);\
posted @ 2011-08-08 09:08  kenter  阅读(268)  评论(1编辑  收藏  举报