查找库中的所有动态初始化
我有几个大型代码库可以编译成动态库。我知道其中一些有一些非常昂贵的动态全局动态初始值设定项。 (也就是说,类/结构的全局实例的构造非常昂贵。)
我想要一种方法来查看这些动态初始化程序在代码中的内容/位置的列表,以便我可以查看它们是否昂贵并且需要重构。我想避免挖掘大量的程序集,因为其中一些库非常大,并且可能包含数百个动态初始化程序(其中许多很小且相当便宜,例如字符串构造)。
有没有一个工具可以帮助我解决这个问题? (我的工具链是Redhat Linux/gcc/cmake。)
I have several large code bases which compile into dynamic libraries. I know that some of these have some very expensive dynamic global dynamic initializers. (That is, global instances of classes/structs which are very expensive to construct.)
I would like a way to view a list of what/where these dynamic initializers are in the code so I can see if they are expensive and need to be refactored. I'd like to avoid digging through a lot of assembly as some of these libraries are quite large and probably contain hundreds of dynamic initializers (many of them small and fairly cheap, like string construction).
Is there a tool that can help me with this? (My tool chain is Redhat Linux/gcc/cmake.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 valgrind 的 callgrind 工具下运行您的代码怎么样,该工具将分析其执行情况(我假设当您说昂贵时您指的是 CPU,而不是 I/O)。编写一个小测试程序,除了加载您关心的许多事情之外什么也不做,然后分析配置文件(例如,在 callgrind 输出文件上使用图形工具 kcachegrind)。
How about running your code under valgrind's callgrind tool, which will profile its execution (I am assuming when you said expensive you meant in terms of CPU, not I/O). Write a small test program which does nothing other than load these many things you are concerned about, and then analyze the profile (e.g. using the graphical tool kcachegrind on the callgrind output file).