Corona® Profiler- A Line-by-Line Analysis of Your Code - New Update

I just noticed this:

“…We actually dynamically adjusted the quality of the game by looking at the average FPS over the last 10 or so frames and if it reached below a threshold we turned off Particle candy and replaced the effects with lower performance counterparts. For example, instead of explosions with PC we just placed a white circle. There was so much going on the screen the player didnt notice and PC did not make it to the top 10 slowest functions list…”

WOW! Are you telling me that looking at the FPS and pausing PC during high drama on the screen you can bring the PC time share to almost nothing (replacing the explosion by a white circle)? That’s just incredible! I HAVE to try this!

Thanks for all the tricks to improve fast pace game. I appreciate it.

Mo [import]uid: 49236 topic_id: 17975 reply_id: 74969[/import]

Hello Community,
We have released an update for Corona profiler. Please download it and let us know if you are having any problems. Details on whats been updated are:

  • Subdirectory support: you can now have source files (including profiler.lua itself) inside subdirectories for better organization of your code.

  • Verbose mode: you can now view under-the-hood functions seen by the lua profiler and display them on the viewing screen. Although the exact name of the functions are known only to Ansca you can see exactly how much time is taken by these functions. you can use it like this:

profiler.startProfiler({name = "test", time = 10000, delay = 1000, verbose = true})  
  • Percentage display: by popular demand, we have included a percentage on the view screen. This is a more quantitative way of viewing how much time relative to the parent function a node is taking. It is equivalent to the node size and color.

Thank you for your support and let us know if you have any problems. We are still working on our new website and we hope to have our own forum there or if we make it on the third party tool list then we will have our own subforum to keep things more organized.

Your support is appreciated,
-M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 74960[/import]

Lemsim,

1- How do you enable the verbose mode or is it already on? How can you tell?

oops we forgot to include the updated documentation, dont worry not much has changed except the verbose mode info. you can enable verbose mode like this:

 profiler.startProfiler({name = "test", time = 10000, delay = 1000, verbose = true})

beware that you will see some strange names that are foreign to us as well. We figured "?215” is the profiler overhead itself since the subnodes link back to profiler code. However the rest of the nodes are anyone’s guess since they seem to be referring to C code, anything from physics to sound to display object transformations. We will have to get Ansca’s expertise on this since it is closed source to us.

As for the dynamic game quality feature. Its fairly easy to do, just check the time it takes to execute say 60 frames and you can calculate an average FPS. Then you can turn off PC, reduce the amount of sound channels, turn off ambiance sounds or anything else you can think of.

As for the memory profiler, it is in the works. We have decided to include it as an update so everyone who already bought profiler will get it for free.
Good luck coding,
M.Y. Developers
[import]uid: 55057 topic_id: 17975 reply_id: 74983[/import]

Free is GOOD! Any time frame? I NEEEED this!!

Thanks, it works great. I can see now what is actually happening. You are right, it will be great if ANSCA could tell you what process is running like physics…not a show stopper for me.

The only thing I can thing of use different color for those internal processes so they pop out but again absolutely not a show stopper.

I am so happy you decided to share this tool with all of us. Love the support as well. First rate! Your profiler belong to the 3rd party tools list on the Ansca site big time.

Thanks,

Mo.

[import]uid: 49236 topic_id: 17975 reply_id: 74988[/import]

Just a quick note to say THANK YOU M.Y Develloper! for the amazing support you guys provide. I sent you my code to check out for that problem I had (not being able to see the specific line of codes on the profiler but only see the line#) Couple hours later (YES couple hours!!) I was up and running.

Simply amazing and refreshing at the same time. First rate.

THANKS!

Mo [import]uid: 49236 topic_id: 17975 reply_id: 75068[/import]

Hello Mo,

You are welcome and we are very glad that we could help you. Thank you and we appreciate your support.

-M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 75519[/import]

Hello Community,
Please check out our new website at
http://www.mydevelopersgames.com/site/

And let us know what you think of the new update!

And the first 5 customers to buy the new version get a 20% discount!

Thanks,
M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 75589[/import]

Thx for the coupon !
(Ansca, please do a special 3rd party for this class)

I’m on mac, I don’t see what
profiler.startProfiler({name = “test”, time = 10000, delay = 1000});
profiler.viewProfilerResult(“test”, 1);
does :
If I put it or not, I have the same results : go to sandbox and open profiletime.html to see the results…

As for Mode Selection, what is the default : get one type of result ? An option to get the 3 charts generated would be possible ?

Sorry for the questions, I just discovered your app. [import]uid: 9328 topic_id: 17975 reply_id: 75602[/import]

Couple of questions. About file filter. I have noticed that even putting the full name of the particle candy (with .lua) and FX candy, I still see them reported in the memory time line. I also see in your doc you are using “particle” (in your PDF doc) was that a typo? What is the format of the file name we need to had to the profiler table?

Am I right to asume that if PC is excluded then I should not see any code related to PC?

I also suggest to switch to maybe green and red in the next version. Blue and green are hard to differentiate.

Some more info on the mode 2 wil be helpful. How to use it?

Keep up the GREAT work guys!

Mo

Edit: here the settings I am using

profiler = require “Profiler”; profiler.startProfiler({name = “myProfile”, time = 20000,  verbose = false, mode = 3,resolution = 1, fileFilter = {“lib_particle_candy.lua”, “lib_particleEffects_01.lua”, “Profiler.lua”}}); [import]uid: 49236 topic_id: 17975 reply_id: 75601[/import]

I feel compelled to mention that this was easily the best purchase under $10 I’ve made all year.

The new memory timeline is awesome. [import]uid: 49447 topic_id: 17975 reply_id: 75613[/import]

Lemsim,
Yes if you filter PC you should see a huge performance boost when using the profiler. the reason you still see it on the timeline is because when a file is filtered out, returns/calls are still profiled but lines are not. The reason for this is say for instance you have this scenario
Function A calls function B
Function B is very slow
Function A is fast except its call to B
Function B is filtered

If we did not profile the call/return statements then you would function A would appear to be very fast.

We can make it so the function does not appear on the profiler itself. Would that be something you want?

oh and concerning the documentation

I also see in your doc you are using “particle” (in your PDF doc) was that a typo?
[/code]
in this case the filter just looks to see if the filename path contains “particle”. you can do a few things with this for instance:
You can filter out entire directories
You can filter out multiple files
You can make your filter as specific as you want

Hope this clarifies that, we will update it on the documentation as well.
Merry Christmas,
M.Y. Developers
[import]uid: 55057 topic_id: 17975 reply_id: 75630[/import]

Antheor,
Thanks for your question, it will only make our documentation better so please ask!
On to your questions

  1. If I put it or not, I have the same results : go to sandbox and open profiletime.html to see the results…
profiler.startProfiler({name = "test", time = 10000, delay = 1000});  
profiler.viewProfilerResult("test", 1);  

yes in this case it would make no difference, esp on a Mac since you cannot launch URLs from corona. On a windows all this would do would launch the plot twice. However, the usefulness of this is clear when you want to save old profile results to compare to later. An idea that we have been using is use the date or some unique identifier when you start profiler so you can view the results and compare your progress. For instance like this

profiler.startProfiler({name = "12252011", time = 10000, delay = 1000});  

And then on new years (or anytime of course) if we wanted to see how much our new code improved/degraded performance we would say

profiler.viewProfilerResult("12252011", 1);  


As for Mode Selection, what is the default : get one type of result ? An option to get the 3 charts generated would be possible ?

The default mode is 1, you can change the default mode by going to line 535 in profiler.lua

params.mode = params.mode or 1  

you can change it to whatever you like

Merry Christmas!
Thank You,
M.Y. Developers
[import]uid: 55057 topic_id: 17975 reply_id: 75631[/import]

Producerism,

Thank you! We really appreciate your support. We are hoping to be on the 3rd party tools list so please help us spread the word.

Merry Christmas!
-M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 75632[/import]

I’m trying to guess why Profiler finds a mem leak in the following function. Okay I have already done a post (YAL question), but I’m here because there’s something apparently not working with my profiler graph (windows):
Whatever the time param, may mem time line goes always to 3500.

And here is the code :slight_smile:

[code]
_W, _H = display.contentWidth, display.contentHeight;
local effectLayer = display.newGroup(); local mRandom = math.random

profiler = require “Profiler”; profiler.startProfiler({time =20000, delay = 1000, mode=3 });
– I change time with no difference on profiler log …

local function doLightnings()

– gundersen code inserted in a Layer :
local lines = display.newGroup()
effectLayer:insert(lines)

local function drawLightning(x1, y1, x2, y2, displace, r, g, b)

if displace < 1 then
–glow around lightning
for i = 1, 2 do
local line = display.newLine(x1, y1, x2, y2)
line:setColor(r, g, b)
line.width = 20 / i
line.alpha = 0.05 * i
lines:insert(line)
end
–bolt itself
local line = display.newLine(x1, y1, x2, y2)
line:setColor(r, g, b)
lines:insert(line)
else
local midx = (x2+x1)*0.5
local midy = (y2+y1)*0.5
midx = midx + (mRandom(0, 1) - 0.5)*displace
midy = midy + (mRandom(0, 1) - 0.5)*displace
drawLightning(x1, y1, midx, midy, displace*0.5, r, g, b)
drawLightning(x2, y2, midx, midy, displace*0.5, r, g, b)
end
end

local function timerDraw(e)
timer.cancel( e.source)
drawLightning( 0, 0, _W, _H,100, 255, 100, 100)

local function timerClear(e)
timer.cancel( e.source )
display.remove(lines)
lines = nil
local lines = display.newGroup()
effectLayer:insert(lines)
end

timer.performWithDelay(mRandom(300), timerClear, 1)
timer.performWithDelay(mRandom(3000), timerDraw, 1)

end

– tmr launch
timer.performWithDelay(mRandom(2000)+1000, timerDraw, 1)

end

doLightnings()
[/code] [import]uid: 9328 topic_id: 17975 reply_id: 76747[/import]

Hello Antheor,
Apologies for any inconvenience this may have caused. We were able to replicate the problem and we are looking at it. Have you had this problem with any other piece of code?

Thanks,
M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 76786[/import]

Can you tell if the profiler takes as much time that you ask for ( meaning if you double the time, the profiler will take that much to finish)?

I was in the impression that the X coordinate of the memory graph was the number of code lines proccessed. Which to means that if the app do not have many code lines to process than no matter how long you set the profiling time the graph will alawsys show you the same amount of lines processed. Try adding a enter frame with a fake function or a simple print and see if that graph length changes.

Again please take this with a grain of salt. It is just my current understanding of how profiler and i could be really wrong!

Mo [import]uid: 49236 topic_id: 17975 reply_id: 76787[/import]

Hello Antheor,
It seems when we comment out profiler there is a runtime error that occurs at line 30: lines is a nil value. This is the reason why profiler stops. The error is a little subtle but you have an extra local identifier at line 46
Please change

local lines = display.newGroup()  

to

lines = display.newGroup()  

And you problem will be solved. Not sure why the runtime error did not show up while profiler was running, perhaps Lua’s debugging facilities suppress such errors when inside a debug hook? At any case thanks for bringing this to our attention.

M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 76788[/import]

Hello Mo,
Yes you are correct. It was done this way because we did not want to mix memory profiling and performance profiling in the same graph. If the X axis were time based then it may be hard to see exactly what is going on in faster lines of code and memory leaks can occur in both fast and slow lines of code.

oh and Happy new year!

Thanks for your input,
M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 76789[/import]

Thank you for your confirmation.

Did you have a chance to look into the suggestion I made about flagging a specific function during the memory profiling? maybe coloring it in red.

“IF it is possible to do” , I will love it since it will help tremendously to track functions that produce leaks. Sure you can move along the graph and see where all those functions but it is very hard to keep track since there is only two colors (by the way those colors, blue and green, are also difficult to differentiate some time)

Happy New Year too! If you continue to producing such a great Corona tools, I predict 2012 will be a great year for you guys! Thanks for those tools.

Take care,

Mo

ps: Another suggestion if I may, will be to able to adjust the Y scale on the memory graph. Sometimes the graph seems to increase a lot but if you look at the actual numbers on the Y scale, the changes sometimes are very small and not worth looking for a leak. It just that visually it looks huge because of the auto-scaling. Not a show stopper of course. [import]uid: 49236 topic_id: 17975 reply_id: 76795[/import]

M.Y., sorry for the report, the correction solved indeed the time param question…

Thx for your support. [import]uid: 9328 topic_id: 17975 reply_id: 76894[/import]