Alexey Bruevich
2014-08-25 16:11:01 UTC
Hi, I have successfully implement LuJIT profiler in our project,  but encountered with next difficulties:
Consider next code:
cont={}
function sleep(n)
  os.execute("sleep " .. tonumber(n))
end
function cont.a()
  sleep(0.01)
  return 1
end
function cont.b()
  sleep(0.02)
  return 2
end
function cont.c()
  sleep(0.03)Â
  return 3
end
function t()
  for c = 1,50 do
     for i,fn in pairs(cont) do
        print ( 3, fn ,fn() )
     end
  end
end
t()
I run profiler with option luajit-2.1.0-alpha -jp=s5  my_file.lua, and have next output:Â
100% sleep
<- 100% fn < t < file.lua:0:30 < @0x00404a10
In source code I've noticed that function names are deduced from callers (lj_debug_funcname), that's why (I think) we don't have any mention of  cont.{a,b,c} in stack - they are the same (fn) for profiler . Am i right? So if i'm right is there any opportunity to dump (function names) cont.{a,b,c} in stack?
Thank you!
Best regards, Alexey!
Consider next code:
cont={}
function sleep(n)
  os.execute("sleep " .. tonumber(n))
end
function cont.a()
  sleep(0.01)
  return 1
end
function cont.b()
  sleep(0.02)
  return 2
end
function cont.c()
  sleep(0.03)Â
  return 3
end
function t()
  for c = 1,50 do
     for i,fn in pairs(cont) do
        print ( 3, fn ,fn() )
     end
  end
end
t()
I run profiler with option luajit-2.1.0-alpha -jp=s5  my_file.lua, and have next output:Â
100% sleep
<- 100% fn < t < file.lua:0:30 < @0x00404a10
In source code I've noticed that function names are deduced from callers (lj_debug_funcname), that's why (I think) we don't have any mention of  cont.{a,b,c} in stack - they are the same (fn) for profiler . Am i right? So if i'm right is there any opportunity to dump (function names) cont.{a,b,c} in stack?
Thank you!
Best regards, Alexey!