linux c++性能测试函数
来源:互联网 发布:探测网络拓扑 编辑:程序博客网 时间:2024/06/06 18:33
测试函数的运行时间
#include<time.h>#include<sys/time.h>#include<stdio.h>// C++ 多线程编程总结// http://www.cnblogs.com/zhiranok/archive/2012/05/13/cpp_multi_thread.htmlstruct profiler{profiler(const char* func_name){gettimeofday(&tv, NULL);m_func_name=func_name;}~profiler(){struct timeval tv2;gettimeofday(&tv2, NULL);long cost = (tv2.tv_sec - tv.tv_sec) * 1000000 + (tv2.tv_usec - tv.tv_usec);//! post to some manager//test:printf("[%s]cost=%d ms\n",m_func_name,cost);}struct timeval tv;const char * m_func_name;};#define PROFILER() profiler ____profiler_instance##__LINE__(__FUNCTION__)void func(){PROFILER();for(int i=0;i<1000;i++);printf("\n\nfunction is end!\n\n");}int main(){func();return 0;}
0 0
- linux c++性能测试函数
- C语言qsort函数算法性能测试
- C语言函数调用性能测试
- 【Linux C】字符测试函数
- Linux C函数 第一章 字符测试函数
- Linux C 函数参考(字符测试)
- 字符测试函数全集 Linux C
- Linux常用C函数---字符测试篇
- Linux常用C函数-字符测试篇
- Python性能测试函数
- Python函数性能测试
- Linux/Unix性能测试
- linux磁盘性能测试
- linux主机性能测试
- linux磁盘性能测试
- linux性能测试工具
- Linux性能测试工具
- Linux性能测试工具
- Struts2学习笔记之Context Map
- HTML学习笔记之事件处理程序
- java 垃圾回收机制浅析
- 利用intellijidea创建maven多模块项目
- LoadAccelerators 失败的原因
- linux c++性能测试函数
- .htaccess 配置以及相关问题的解释
- IOS 关闭键盘 退出键盘 的5种方式
- two ways of saving figure windows
- grails中使用BASE64加密
- EDIUS把单声道变成立体声的方法
- Python处理网络帧等字节文件——CRC8校验
- 负载均衡
- IOS开发中,SVN如何恢复到某一个版本(以Cornerstone为例)