获得函数执行的次数
2007-04-29 00:42
246 查看
//GetFuncCallTimes.h
#ifndef _GETFUNCCALLTIMES_H
#define _GETFUNCCALLTIMES_H
#include <map>
#include <string>
class CGetFuncCallTimes
{
public:
std::map<std::string, long> call_count;
void Increase(std::string s)
{
++call_count[s];
}
long Count(std::string s)
{
return call_count[s];
}
};
extern CGetFuncCallTimes fct;
#endif
//GetFuncCallTimes.cpp
#include "GetFuncCallTimes.h"
CGetFuncCallTimes fct;
使用方法如下:
在源文件中包含该头文件: #include "GetFuncCallTimes.h"
在需要统计的函数里面加上一行: fct.Increase("function1");
输出时: long lTimes = fct.Count("function1");
#ifndef _GETFUNCCALLTIMES_H
#define _GETFUNCCALLTIMES_H
#include <map>
#include <string>
class CGetFuncCallTimes
{
public:
std::map<std::string, long> call_count;
void Increase(std::string s)
{
++call_count[s];
}
long Count(std::string s)
{
return call_count[s];
}
};
extern CGetFuncCallTimes fct;
#endif
//GetFuncCallTimes.cpp
#include "GetFuncCallTimes.h"
CGetFuncCallTimes fct;
使用方法如下:
在源文件中包含该头文件: #include "GetFuncCallTimes.h"
在需要统计的函数里面加上一行: fct.Increase("function1");
输出时: long lTimes = fct.Count("function1");
相关文章推荐
- 获取php页面执行时间,数据库读写次数,函数调用次数等(THINKphp)
- Java 中的 int 与 Integer 用于 List<Integer> 时,以及通过打印变量检測程序执行和函数调用次数计数
- unity3d 各个函数的执行顺序,回调,顺序,次数等
- 获取php页面执行时间,数据库读写次数,函数调用次数等(THINKphp)
- C#获得当前执行的函数名、当前代码行、源代码文件名
- C#获得当前执行的函数名、当前代码行、源代码文件名
- 绑定事件中 如可控制函数的执行次数
- 让你的PHP也能执行JS并获得JS函数的返回值
- 写一个限制执行次数的函数
- 在JS中统计函数执行次数与执行时间
- Unity3d之MonoBehavior的各个函数的执行顺序,回调,顺序,次数等
- Framework C#获得当前执行的函数名、当前代码行、源代码文件名
- 获取线程中某个函数执行完成所获得的CPU时间量
- Unity3d之MonoBehavior的各个函数的执行顺序,回调,顺序,次数等
- unity中获得一帧中函数执行的时间以及定位性能热点
- 详解JS中统计函数执行次数与执行时间
- Unity3d之MonoBehavior的各个函数的执行顺序,回调,顺序,次数等
- 鼠标滚动一次window.onscroll事件的函数在firfox与Ie中执行的次数不同问题的处理s
- 动态获取桩函数的执行次数
- unity中获得一帧中函数执行的时间…