Measure time taken dynamically linking at program startup?

和自甴很熟 提交于 2019-12-06 14:55:26

Use LD_DEBUG.

try this:

LD_DEBUG=statistics ./myprog

It'll output a short list of various statistics. An example:

xenon-lornix:~> LD_DEBUG=statistics ls
     22833:
     22833:     runtime linker statistics:
     22833:       total startup time in dynamic loader: 2500702 clock cycles
     22833:                 time needed for relocation: 757822 clock cycles (30.3%)
     22833:                      number of relocations: 155
     22833:           number of relocations from cache: 8
     22833:             number of relative relocations: 1253
     22833:                time needed to load objects: 1325154 clock cycles (52.9%)

Shows info about loading/running the ls command.

Using LD_DEBUG=help ./myprog will show names of other options available to use with LD_DEBUG.

More information can be found in the ld.so, ld-linux.so man pages (these are identical actually). A Google search can help with more specifics.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!