Giter Club home page Giter Club logo

luatrace's People

Contributors

erkan-yilmaz avatar geoffleyland avatar justincormack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

luatrace's Issues

luatrace.profile crashes trying to index a local 'thread'

On Mac OS X with lua (and luajit) installed via Homebrew, I have luajit embedded in my 3d graphics engine. I'm then writing the vast majority of the game in lua, which is why I'm interested in the profiler.

Near the top of my main lua file I use:
Luatrace = require("luatrace")

Then when I want to profile a section, I use:
Luatrace.tron({trace_file_name="cms_trace.txt"})

Then I finish it with:
Luatrace.troff()

That does create a cms_trace.txt file that's 56k in size. So I try to run luatrace.profile and it crashes with an access to a nil local value:

tbogdala$ luatrace.profile cms_trace.txt
lua: /usr/local/share/lua/5.1/luatrace/profile.lua:125: attempt to index local 'thread' (a nil value)
stack traceback:
/usr/local/share/lua/5.1/luatrace/profile.lua:125: in function 'call_on_thread'
/usr/local/share/lua/5.1/luatrace/profile.lua:213: in function 'record'
/usr/local/share/lua/5.1/luatrace/trace_file.lua:133: in function 'read'
/usr/local/share/lua/5.1/luatrace/profile.lua:463: in function 'go'
(command line):1: in main chunk

make fails on Ubuntu

Ubuntu (and other Debian distros) puts Lua stuff to "alternative" locations:

LUA_SHAREDIR=/usr/share/lua/5.1
LUA_LIBDIR=/usr/lib/lua/5.1
LUA_INCDIR=/usr/include/lua5.1/

build on msvc

would you provide build/install instructions for msvc? Thanks!

What should I do when I got this numbers?

I got my trace-out.txt with this:

25 154.304
3 0.25
6 0.221
9 0.183
12 0.175
15 0.172
25 0.213
26 0.165
26 279.552
25 640.975
2 0.246
4 0.045

What should I do next?
How can I tell which part of my code is slow?

Thanks!

Make fail about dirname and -I mssing path

Here is the error:

luatrace-master$ make
dirname: missing operand
Try 'dirname --help' for more information.
dirname: missing operand
Try 'dirname --help' for more information.
find: ‘/include’: No such file or directory
dirname: missing operand
Try 'dirname --help' for more information.
/usr/bin/cc -O3 -Wall -Wextra -pedantic -fPIC -shared c/c_hook.c -o lua/luatrace/c_hook.so -lrt -I
cc: error: missing path after ‘-I’
makefile:45: recipe for target 'lua/luatrace/c_hook.so' failed
make: *** [lua/luatrace/c_hook.so] Error 1

How to use for embedded luajit2

Can this be used to write a profiling report for embedded luajit2?

If so, can you add an example to the README.md? I see the example calling tron() and troff() but where are the results?

Error compiling git head (db7fb4ef3ad7a544aeab4b2786a905af47fdd409)

Trying to compile db7fb4e

$ make
/usr/bin/cc -O3 -Wall -Wextra -std=c89 -pedantic -fPIC -shared c/c_hook.c -o lua/luatrace/c_hook.so -lrt -I/usr/include
c/c_hook.c: In function ‘lclock’:
c/c_hook.c:51:19: error: storage size of ‘tp’ isn’t known
c/c_hook.c:52:3: warning: implicit declaration of function ‘clock_gettime’ [-Wimplicit-function-declaration]
c/c_hook.c:52:17: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)
c/c_hook.c:52:17: note: each undeclared identifier is reported only once for each function it appears in
c/c_hook.c:51:19: warning: unused variable ‘tp’ [-Wunused-variable]
c/c_hook.c:54:1: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [lua/luatrace/c_hook.so] Error 1

$ uname -a
Linux vm-arch 3.2.9-1-ARCH #1 SMP PREEMPT Thu Mar 1 09:31:13 CET 2012 x86_64 Intel(R) Core(TM) i5 CPU U 470 @ 1.33GHz GenuineIntel GNU/Linux

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.6.3/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/src/gcc-4.6.3/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --enable-multilib --disable-libssp --enable-checking=release --with-fpmath=sse
Thread model: posix
gcc version 4.6.3 (GCC)

Intermittent errors

The following code makes the luatrace.profile script to fail sometimes.

require "luarocks.require"
require "json"

local luatrace = require "luatrace"

luatrace.tron()
local t = json.decode[[
{
    "friends": [],
    "blah": {},
}
]]
luatrace.troff()

It gives the following error:

ERROR (   1, line     147): counted execution of 0.5 microseconds at line 1 of a function defined at C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:633-650
lua: ...Rocks/rocks//luatrace/scm-2/lua/luatrace\profile.lua:266: attempt to index local 'top' (a nil value)
stack traceback:
        ...Rocks/rocks//luatrace/scm-2/lua/luatrace\profile.lua:266: in function 'record'
        ...ks/rocks//luatrace/scm-2/lua/luatrace\trace_file.lua:142: in function 'read'
        ...Rocks/rocks//luatrace/scm-2/lua/luatrace\profile.lua:459: in function 'go'
        (command line):1: in main chunk
        [C]: ?

The strange thing is that sometimes it works fine.

C:\>lua -lluarocks.require -e "require('luatrace.profile').go()"
Total time 103.50 microseconds
Times in microseconds
Top 20 lines by total time
File:line                                                   Hits   Total    Self   Child | Line
test_json.lua:7                                                1  102.50    1.00  101.50 | local t = json.decode[[
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:650             1   93.50    1.00   92.50 |           end
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:628             3   92.50    2.50   90.00 |              local t = next_token(tt_object_value)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:575             2   90.00    1.50   88.50 |              if t == tt_object_key         then return read_object_key({}) end
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:640             2   69.50    1.00   68.50 |                      if t == tt_object_key then return read_object_key(o) end
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:635             5   32.50    2.50   30.00 |                      local t = next_token(tt_object_key)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:486            25   19.00   19.00    0.00 |                      local b = js_string:byte(pos)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:504             1   18.00    0.50   17.50 |                      local t = next_token(tok)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:524             2   16.50   16.50    0.00 |              return (loadstring("return " .. stringValue ) ())
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:485            14   12.50   12.50    0.00 |              while pos <= #js_string do
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:487            19    9.50    9.50    0.00 |                      local t = tok[b]
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:643             1    9.00    0.50    8.50 |                      if next_token(tt_object_colon) == tt_comment_start then
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:501             2    8.50    1.50    7.00 |              local start = pos
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:641             2    8.00    1.00    7.00 |                      local k = read_string(t)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:493            12    6.00    6.00    0.00 |                      pos = pos + 1
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:636             3    6.00    1.50    4.50 |                      if t == tt_comment_start then
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:494             9    4.50    4.50    0.00 |                      if t~=tt_ignore then return t end
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:488             6    3.00    3.00    0.00 |                      if not t then
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:513             2    2.50    2.50    0.00 |              stringValue = string.gsub(stringValue, "([\\]+)u(%x%x)(%x%x)", function(escape, hex_value_high, hex_value_low)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:512             2    2.00    2.00    0.00 |              local stringValue = js_string:sub(start-1, pos-1)

Top 20 functions by self time
File:lines                                                  Hits   Total    Self   Child | Line
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:484-497        14   54.50   54.50    0.00 |           local function next_token (tok)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:500-536         2   48.50   24.00   24.50 |           local function read_string (tok)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:633-650         4   89.50    9.50   80.00 |           function read_object_key (o)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:458-660         1  101.50    9.00   92.50 |      function decode (js_string)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:627-630         3   92.50    2.50   90.00 |           function read_object_value (o)
test_json.lua:0-0                                              1    2.00    2.00    0.00 | -
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:574-584         3   90.00    1.50   88.50 |           function read_value (t,fromt)
C:\LuaRocks/rocks//json4lua/git-1/lua/json.lua:603-624         1    4.00    0.50    3.50 |           function read_array (o,i)
C:\LuaRocks/rocks//luatrace/scm-2/lua/luatrace.lua:350-358     1    0.00    0.00    0.00 | -

To reproduce, install json4lua with luarocks and run the provided script. The script, a trace that succeeds and a trace that fail are available here.

luatrace is not compatible with strict because unintended global variable

To reproduce:
lua -e'require"strict" lt=require"luatrace" lt.tron()'
Output

lua: /usr/share/lua/5.1/luatrace.lua:305: assign to undeclared variable 'luatrace_exit_trick_file'
stack traceback:
        [C]: in function 'error'
        /usr/share/lua/5.1/strict.lua:23: in function '__newindex'
        /usr/share/lua/5.1/luatrace.lua:305: in function 'luatrace_exit_trick'
        /usr/share/lua/5.1/luatrace.lua:343: in function 'tron'
        (command line):1: in main chunk
        [C]: at 0x004f8b54

To fix just add a

local luatrace_exit_trick_file

before

local function luatrace_exit_trick()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.