//------------------------------------------------------------------------------
// 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", -));
}

最新文章

  1. Neutron 理解 (3): Open vSwitch + GRE/VxLAN 组网 [Netruon Open vSwitch + GRE/VxLAN Virutal Network]
  2. [skill][gdb] gdb 多线程调试
  3. webapi的返回类型,webapi返回图片
  4. CheckListBox的实现方式分析
  5. CS0016: 未能写入输出文件“c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\helloiis\ceb8cab3\4db603d8\App_global.asax.gr73hi-k.dll”--“拒绝访问。 ”
  6. 面试题中遇到的SQL题目
  7. [zt]不到最后一秒你永远不知道结局且震撼你心灵的高端电影
  8. 字符串&数组的相互转换
  9. spring加载hibernate映射文件的几种方式 (转)
  10. Windows下安装Emacs+Sbcl+Slime
  11. Python与MySQL首次交互
  12. Python 第一篇:python简介和入门
  13. mybatis转义符(转)
  14. 【java】io流之字节输出流:java.io.OutputStream类及子类java.io.FileOutputStream
  15. 自用最小生成树模板(基于Kruskal)
  16. Python list 初始化技巧
  17. cmder使用简介
  18. Zookeeper+Kafka集群部署
  19. python-selenium无法调用浏览器的问题
  20. python 数据库连接及操作

热门文章

  1. SQL语句执行与结果集的获取
  2. lxml模块(应用xpath技术)
  3. mybatis开发dao的方式
  4. 基于iframe的CFS(Cross Frame Script)和Clickjacking(点击劫持)攻击
  5. Selenium2学习(十七)-- js处理日历控件(修改readonly属性)
  6. CSS基础语法(一) CSS的3种引入
  7. 人多qiu是好
  8. 【转】ssh timed out 超时解决方案
  9. QT学习之窗口右键菜单
  10. ZJOI2019Day2余姚中学游记(4.23~4.26)