further
Lua performance analysis tools
principle
Similar gperftools, by timer signal callbacks to view the call stack, calls to locate hot spots
characteristic
- Simple, just a few lines of code, you can output the results
- Accurate, compared lua Hook, sampling timing more accurately capture mode execution hot lua
- Lightweight, because it is sampled, a row lua hook, can minimize the impact of running the host program directly comparable
- Intuitive, call graph output can directly see the hot spots and call relations
use
Lua code
- introducing libplua.so local P = the require "libplua" - Sampling opening - Parameter 1: sampling time (in seconds), sampling has been represents 0 - 2 parameters: the sampling result file p.start (0, "call.pro ") do_some_thing () - end of the sampling, the output file p.stop () - the result into the txt format p.text (" call.pro "," call.txt ") - the result converted into dot format available graphviz view p.dot ( "call.pro", "call.dot") - the result converted into svg format that can be viewed directly opens a browser p.svg ( "call.pro", "call.svg ")
Compile
- Install lua 5.3
- Install graphviz
- Compile pLua
$ cmake . $ make