chromium之tracked
2024-10-21 06:26:18
//------------------------------------------------------------------------------
// Tracked is the base class for all tracked objects. During construction, it
// registers the fact that an instance was created, and at destruction time, it
// records that event. The instance may be tagged with a name, which is refered
// to as its Location. The Location is a file and line number, most
// typically indicated where the object was constructed. In some cases, as the
// object's significance is refined (for example, a Task object is augmented to
// do additonal things), its Location may be redefined to that later location. // Tracking includes (for each instance) recording the birth thread, death
// thread, and duration of life (from construction to destruction). All this
// data is accumulated and filtered for review at about:objects.
信息跟踪收集,用于统计分析的工具
下面的代码是不是很熟悉,FROM_HERE
message_loop->PostTask(FROM_HERE,...) #define FROM_HERE tracked_objects::Location(__FUNCTION__, __FILE__, __LINE__)
构造函数如下:
class Location {
public:
// Constructor should be called with a long-lived char*, such as __FILE__.
// It assumes the provided value will persist as a global constant, and it
// will not make a copy of it.
Location(const char* function_name, const char* file_name, int line_number)
: function_name_(function_name),
file_name_(file_name),
line_number_(line_number) { }
}
记录了函数名,文件名,行号
不过,只有在调试模式,才会有比较详细的统计信息
#ifndef NDEBUG
#ifndef TRACK_ALL_TASK_OBJECTS
#define TRACK_ALL_TASK_OBJECTS
#endif // TRACK_ALL_TASK_OBJECTS
#endif // NDEBUG
调试模式下,多了一个没见过的ThreadData,可以分析分析chromium之tracked_objects
Tracked::Tracked() : tracked_births_(NULL), tracked_birth_time_(Time::Now()) {
if (!ThreadData::IsActive())
return;
SetBirthPlace(Location("NoFunctionName", "NeedToSetBirthPlace", -));
}
最新文章
- Neutron 理解 (3): Open vSwitch + GRE/VxLAN 组网 [Netruon Open vSwitch + GRE/VxLAN Virutal Network]
- [skill][gdb] gdb 多线程调试
- webapi的返回类型,webapi返回图片
- CheckListBox的实现方式分析
- CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\helloiis\ceb8cab3\4db603d8\App_global.asax.gr73hi-k.dll”--“拒绝访问。 ”
- 面试题中遇到的SQL题目
- [zt]不到最后一秒你永远不知道结局且震撼你心灵的高端电影
- 字符串&;数组的相互转换
- spring加载hibernate映射文件的几种方式 (转)
- Windows下安装Emacs+Sbcl+Slime
- Python与MySQL首次交互
- Python 第一篇:python简介和入门
- mybatis转义符(转)
- 【java】io流之字节输出流:java.io.OutputStream类及子类java.io.FileOutputStream
- 自用最小生成树模板(基于Kruskal)
- Python list 初始化技巧
- cmder使用简介
- Zookeeper+Kafka集群部署
- python-selenium无法调用浏览器的问题
- python 数据库连接及操作