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

Antheor,
Thanks for bringing that to our attention. The issue is resolved.
Can anyone recommend a better web host than Intuit?
-M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 68778[/import]

No problem.
I have check the demo, looks good, even if I’m not sure to understand the different columns ):slight_smile:

Maybe you could add a sorting menu : by performance (current) / from line 1 to last / other (?) [import]uid: 9328 topic_id: 17975 reply_id: 68808[/import]

Antheor,
Sorry if that is not clear. Basically you have a tree data structure with nodes representing lines of code. Each subtree is sorted and the top 10 slowest nodes (which themselves are lines of code) are displayed. If any of these nodes are functions then the process repeats. Here is the documentation, it might help clear some misunderstanding. https://sites.google.com/site/mydevelopersgames/ProfilerDocumentation.pdf?attredirects=0&d=1

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

Thx [import]uid: 9328 topic_id: 17975 reply_id: 68815[/import]

If you are still looking for a webhost, I have used Dreamhost for many years with no real issues.

http://www.dreamhost.com
[import]uid: 5317 topic_id: 17975 reply_id: 68839[/import]

Antheor,
No Problem, let us know if you have any more problems. Was the documentation clear?

Mike,
Thanks for the suggestion. For the money the value looks very good!

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

Yes it was.
It’s a bit early to optimize my app (no finished at all), but I know I won’t resist to buy your app : the price is quite correct and who would no want to spice its app up :slight_smile: [import]uid: 9328 topic_id: 17975 reply_id: 68998[/import]

Thank you for your interest in our app :slight_smile: Good luck on your app.

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

I’ll second that Dreamhost suggestion. Solid, cheap, helpful.

Just purchased Ultimote and will take a look at Profile soon. Same boat as Antheor but if they work I think both could be really useful, so keep it up guys. :slight_smile: [import]uid: 41884 topic_id: 17975 reply_id: 69836[/import]

We took your suggestions and got Dreamhost, in the process of migrating our website over, Thanks!

@richard9
Thanks for the support and let us know if you run into any problems. :o)

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

Hi

I just bought Corona Profiler and I have to say WOW! It is fun to see what takes longest in my code. I am still learning on how to actually use it and would love some kind of tutorial when you get a chance. I am assuming that the ms numbers are the TOTAL amount of time the code spend on each of the function or line of code while the profiling is on.

Another question if I may. I can see that in the demo that the actual line of code (or function name) is displayed. But on my code only the code line and the ms amount is displayed. Am I missing something? I also noticed that external lua code (external to my code) do shows the actual line of code but not my actual lua code. For instance it shows the actual line of codes for Particle Candy or joystick.lua but for own code, it only shows the line number and the amount of ms?

In any event, thank you for a great tool!

Mo

ps: I know the size of the box indicate the time percentage but it will be great if the system also displayed the actual % (as of the total time) By the way is the color of boxes has any significance? Thanks.

ps2: just a quick note about my tutorial request above. I did not meant a tutorial on how to use the library (which is super easy to use!). I would like to see maybe some of the experiences you had optimizing your space game for instance. I am sure every single function did not need optimizing I am sure. What was your strategy in optomizing your game? What was the before and after results (especially running on older devices)? I will LOVE a little write up on this. Of course if a user of the library already used it to improve his/her game, love to hear about it. I have a feeling that this library is a super tool for all fast pace games that need an extra boost of performance! Thanks.
[import]uid: 49236 topic_id: 17975 reply_id: 71530[/import]

Hello lemsim,
thank you for your comments and we are glad you are enjoying profiler. As for your specific questions
I am assuming that the ms numbers are the TOTAL amount of time the code spend on each of the function or line of code while the profiling is on.
yes each line is the total amount of time spent in that function over the course of the entire profile time, we considered doing separate timings for each function call but that would have taken too much memory and profiler overhead would have been too much. For instance, if your function calls print() only once but another function calls it many times, it will appear to take more time than it does for that function.

For instance it shows the actual line of codes for Particle Candy or joystick.lua but for own code, it only shows the line number and the amount of ms?[/code]
the built in lua debugger functions oddly do not give the function name but only give the filename and line number. In order to display the actual line of code we had to read the .lua files themselves. can you send us a screenshot of the problem? perhaps your code is within a subdirectory or has special characters? It seems that the .lua file was not found where it was expected.

I know the size of the box indicate the time percentage but it will be great if the system also displayed the actual % (as of the total time)
Excellent idea! we will post that in a future update.

By the way is the color of boxes has any significance? Thanks.
This was also brought up by someone else, we will update the documentation to make it more clear. The colors and box height represents the percentage of time taken by that particular line of code with respect to its parent function. For instance if line X takes 90% of the time and line Y takes 10%, then X will appear 90% red and 10% green and vice versa.

I would like to see maybe some of the experiences you had optimizing your space game for instance.
Yes we were thinking of writing about our experience in the forums as we had some very surprising results in some cases. For instance, we implemented lookup tables for standard trig libraries like sin, cos, tan and we just assumed they would be faster than the corresponding lua libraries. Instead, the standard libraries were about 50% faster. This was confirmed on the device itself. We also used an interesting method to get distances without using the square-root operation found here
http://www.dspguru.com/dsp/tricks/magnitude-estimator
but to our surprise the standard libraries were faster.
Another thing that was surprising was controlling the velocities of objects via continuously updating x,y coordinates vs letting the physics engine handle it. Turns out the physics engine is faster because it is handled in low level C.

A more formal writeup of these findings is necessary and we will provide that when we get enough data/validate findings.

Thank you for your support,
M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 71659[/import]

WOW! Thank you so much for the great info. I really appreciated it. Yes a write up of your experience in optimizing your game will be much appreciated when you get a chance. Actually, I think it will help you sell more copies since I am sure a blog post here will be read buy more people than a post that may or not get a chance to be read by most.

For instance with your soft, I was able to find 2 lines of codes that are taking a “huge” amount of time to run (540 ms each for a total profiler time of 20000 ms) See the code below for more details. planets and rocks are local table (to the module) Not sure why getting the x and y elements of those local tables takes so much time that they are detected by your soft. Not sure what to do about it yet but it sure nice to found out about it using your soft.

Also here the screen shot you asked about that shows only external lua codes(to my own code) have the lines described. Hope this will help you. Let me know if you need more info.

http://s11.postimage.org/bfn600zeb/profiler1.jpg
THANK YOU!


[lua]local function checkPlanets() -------- THE ALL FUNCTION TAKES = 2152 ms (LINE#1273)

for p = 1, gameLevel do
if planets[p].health > 0 then

planets[p].rotation = planets[p].rotation + planets[p].rate

for i, v in pairs(rocks) do – THIS LINE#1289 = 384 ms

local px = planets[p].x - rocks[i].x — THIS LINE#1292 TAKES = 540 ms!
local py = planets[p].y - rocks[i].y — THIS LINE#1293 ALSO TAKES = 540 ms!
local distanceP = px*px + py*py ------------THIS LINE#1294 TAKES = 125 ms

if distanceP > 3000 then explodeFlagP = false end – THIS LINE#1296 = 121 ms
if distanceP < 1000 and explodeFlagP == false then planet1Hit(i,p) end ---- THIS LINE#1297 = 123 ms

end
end

end

end[/lua]
[import]uid: 49236 topic_id: 17975 reply_id: 71797[/import]

Hi lemsim,
is gameScreen.lua in a subdirectory? also, does your main.lua function show the lines or just gameScreen.lua?

as for the code sample you gave, this is a sort of collision checker right? Are you running this every frame? One strategy we employed with dramatic results is performing non-time critical tasks every other or every 7 frames. For instance, we profiled the main game loop and we discovered the AI scripts were taking too long, so instead we called the AI functions every 7 frames instead of every frame. This had an unnoticeable effect on AI responsiveness but a dramatic increase in speed.

also, try not to use pairs. if you can index rocks the same way you index planets (via a number index) then you should use the same for loop structure. You should only use pairs when you want to iterate through an associative array. for instance

rocksN = {[1] = "r",[2] = "b"} -- you should use the number directly rocksA = {["first"] = "a", ["second"] = "b"} --you can use pairs
that being said, for performance you should not use associative arrays.

And one more thing. If you are doing a simple collision detection you should really consider converting everything to a physics engine based simulation. The physics engine uses sophisticated techniques so it does not have to compute the distance to every single object like your code does. And it has access to low level C functions which are considerably faster and optimized.

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

I do not know how to thank you enough for all your GREAT suggestions! I will check them all and see what I can come up with.

In term of subdirectory, i do not think so. Both gameScreen, main.lua and others .lua are all in the same directory (including profiler.lua) The only thing I do is use dropBox so my directory resides in dropBox (so I can have an automatic backup and can work on the code from everywhere. Would that be causing the problem. In term of code lines, none of the code I wrote has any lines displayed (only line# and time) But all the other external lua like particle candy or joystick.lua shows the exact code. Not sure why. I will try to use your profiler on some test code and see.
Without your amazing profiler I would have never found what I am finding now. My is a fast action game and I can see that I will need to optimized it quite a bit (runs super in ipad 2 but has some issue with ipod 3 gen for instance) I have to admit that I started my game in a “lazy” way and now that it has grown I really need to clean it up!

THANK YOU!

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

Lemsim,
We had the exact same problem with space conquest, we started it the lazy way and the only platform it would run on was ipad2, which obviously is not a huge market. But after optimizing with profiler our game now runs on android phones as well. Perhaps the best realization was the time splitting technique. Initially we went for elegance and called act() functions for everything even if it had nothing in it. well turns out the amount of time calling and returning from function really adds up and slows down your game a lot. Many of these functions like shield recharging function could be called once every 15 or so frames, in effect speeding the game loop by 15x, that’s fast!

oh and you should check out this article
http://developer.anscamobile.com/content/performance-and-optimization
try caching your variables so the table lookup operation will not be performed as often.
one more thing to consider:
“Cache properties in a local variable

If you are constantly accessing a property of a table but not changing its value, then you should cache that value. There is a slight performance penalty to doing property lookups in a table. For objects created by Ansca’s api’s — such as the display object returned by display.newImage() - the penalty is even higher.

so constantly accessing the x and y in your game loop is slow, you should delegate it to the physics engine.

good luck optimizing and thank you for all the good words,
M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 71838[/import]

Hello again.

Thank you so much for all your suggestions. I values them 1000X more than the cost I paid for your great app!

It is now so easy to experiment and see what code work faster than an another. No more guess work!

I wish you the best for your app!

Mo.

ps: I am still working on the problem with the line codes issue but I am sure it is something that I am doing since i can see the line codes on libraries like particle candy or joystick.lua. It is just a pain to refer each time to the line# rather than the actual line code (easier to spot and line# changes every time you make a change!) As I said I will try to move my app code locally (rather than dropBox) and see. I will report here if I found something. [import]uid: 49236 topic_id: 17975 reply_id: 71929[/import]

Thank you and best of luck on your app. Dropbox is probably not the issue as we use dropbox for all our code as well. We will look into the issue but let us know if you find anything.
-M.Y. Developers [import]uid: 55057 topic_id: 17975 reply_id: 72041[/import]

I will. Thank you very much.

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

You are welcome and thank you for your support.
-M.Y. Developers
[import]uid: 55057 topic_id: 17975 reply_id: 73373[/import]