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

202 replies [Last post]
M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Hello Community,

Please visit our website: http://www.mydevelopersgames.com/site/

-New in this version

  • Memory Leak Timeline!
  • Memory Profiler
  • File Filters
  • Profiler Resolution (for speed)

We are proud to present Corona® Profiler, the easiest way to get a line by line performance report of your Corona® App. Profiler will help you optimize your code by measuring the execution time for each line of your program and giving you a report of which lines need work.
We used profiler to optimize our game Space Conquest and we improved user ratings and performance on lower end devices. You can see the actual profiler report at our website
http://www.mydevelopersgames.com/site/

New update coming up
Corona Profiler will be getting a memory profiler feature that will let you see the total memory consumption per line of code. This will allow you to narrow down troublesome lines of code that may be leaking memory. If all goes well the update will be available within the next few days so all existing users will get it for free. The price will go up once we are done implementing this feature so please buy our quality product today!


Thank you for your support,
M.Y. Developers

Replies

xxxfanta
User offline. Last seen 7 years 27 weeks ago. Offline
Joined: 25 Dec 2010

I've stumbled across your 2 apps today and i guess they could be very helpful (especially ultimote once it's available for ios).

You do a great job! Keep it up!
And let us know for any discounts :D

(and maybe refining some of the images :) )

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Thanks for your comments!
Ultimote is a source code distribution so you can compile it yourself for your iOS device. We decided to go this way because we expect to add features as soon as they are requested by the community and going through the app store would take too long.

As for the discounts, we have discounts available right now for both our products (ultimote and profiler). :D

As for the images, yes we are working on the improving our graphic design. :D

Thank you
M.Y. Developers

xxxfanta
User offline. Last seen 7 years 27 weeks ago. Offline
Joined: 25 Dec 2010

Whoops? I just saw Profiler1Dollar ;)

Oh I actually tried to download Ultimote from http://www.mygamedevelopers.com/Corona-Ultimote.html, but the link isn't clickable in Safari (actually I just realized it works with Firefox).

Something you might want to fix :)

Let us know if there are any updates. I enjoy usefull tools as this!

martin.edmaier
User offline. Last seen 3 years 48 weeks ago. Offline
Joined: 25 Aug 2011

Works great on windows;)

don
User offline. Last seen 6 years 32 weeks ago. Offline
Joined: 24 Jan 2011

I purchased the Profiler. I noticed you're using the module(..., package.seeall) as well as globals. Can you create a version that does not modify the global space? I have a globals checker that errors out when variables aren't declared.

Update: Hmm maybe it's a quick fix, I duplicated the undeclared vars on line 20 as locals. previousMemory, previousLineAll, etc and my errors went away

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Don,
We fixed the issue, sorry about the typo there. Where can I find this globals checker?
Thanks,
M.Y. Developers

don
User offline. Last seen 6 years 32 weeks ago. Offline
Joined: 24 Jan 2011

Hi M.Y. Developers,

I don't recall where I got the code from. But I integrated it into the Spriteloq API you can d/l here: http://www.loqheart.com/spriteloq/downloads/extras/spriteloq_libs.zip

check out loq_util:
http://www.loqheart.com/spriteloq/apidocs/files/loq_util-lua.html#Global_declaration_of_variables_before_usage

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

xxxfanta,
Thanks for letting us know about the safari issue. It is strange because everything seems to be working fine with safari v5.1
Did you have any problems getting the product?
Thanks,
M.Y. Developers

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Thank you Don, this looks like a very useful tool! Are you having any more issues with Profiler?
-M.Y. Developers

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Martin,
Thanks for your comments, you are our biggest fan! :o)
-M.Y. Developers

don
User offline. Last seen 6 years 32 weeks ago. Offline
Joined: 24 Jan 2011

Well it seems to work as advertised, but the slowdown has an adverse effect on physics. So much so that I can't play the game effectively when the profiler is running, so there are certain things I can't profile. I don't seem to have this problem with the lua pepperfish profiler.

Also when running for 60 seconds Corona seems to hang. At 10 seconds it's fine.

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

don,
Pepperfish only profiles functions, Corona Profiler profiles line by line to give you much finer results so the overhead is expected to be a more, however all lines are effected equally (including C functions such as physics) so the results are still valid. We will give the option for profiling only functions in our next update.
Thank you,
As for the hanging at 60 seconds issue, we tested the profiler for 60 seconds on our game Space Conquest (these are the profiler results posted on our website live demo) and everything seemed to work fine. Are you getting any errors messages?

M.Y. developers

don
User offline. Last seen 6 years 32 weeks ago. Offline
Joined: 24 Jan 2011

Sorry no error messages. After it hung once I didn't attempt it again. I just set it to 10 seconds. I can try it again in a bit and report the results.

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Since saving and loading can take multiple full frames (and hopefully your game loop does not take an entire frame) it has to profile a lot more instructions so it may hang. We experienced this during game loading but the program always recovers given enough time, how long did you wait and what was going on in your program when it hung?
Thanks,
-M.Y. Developers

don
User offline. Last seen 6 years 32 weeks ago. Offline
Joined: 24 Jan 2011

Hmm I just tried it again 3 times on three different levels. No hang ups this time. Tried it with delay. My game crash free as far as I know. But on rare occasions on device the game and device lock up. I wonder if there's some race condition that the Profiler revealed.

*shrug* I don't know. If I find anymore clues as to how to reproduce the hangup I'll let you know.

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Don,
Yeah when you try to profile during game loading profiler overhead is significant. A delay is useful to bypass the loading stage to get to your main game loop. Hope you are finding the program useful so far.
-M.Y. Developers

don
User offline. Last seen 6 years 32 weeks ago. Offline
Joined: 24 Jan 2011

Yeah the first time I tried it with delay so the loading wouldn't affect the code I actually wanted to profile, but that's when I had the hang up.

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Don,
Thanks for letting us know about the issue, we will look into it.
-M.Y. Developers

Antheor
User offline. Last seen 4 years 35 weeks ago. Offline
Joined: 22 Sep 2010

The demo link sends "page not found" ...

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Antheor,
Thanks for bringing that to our attention. The issue is resolved.
Can anyone recommend a better web host than Intuit?
-M.Y. Developers

Antheor
User offline. Last seen 4 years 35 weeks ago. Offline
Joined: 22 Sep 2010

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

Maybe you could add a sorting menu : by performance (current) / from line 1 to last / other (?)

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

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

Antheor
User offline. Last seen 4 years 35 weeks ago. Offline
Joined: 22 Sep 2010

Thx

mike4
User offline. Last seen 7 years 1 week ago. Offline
Joined: 22 Feb 2010

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

http://www.dreamhost.com

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

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

Antheor
User offline. Last seen 4 years 35 weeks ago. Offline
Joined: 22 Sep 2010

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 :)

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

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

-M.Y. Developers

richard9
User offline. Last seen 2 years 5 weeks ago. Offline
Joined: 28 Feb 2011

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. :)

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

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

lemsim
User offline. Last seen 7 years 43 weeks ago. Offline
Joined: 30 Mar 2011

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.

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

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?
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

lemsim
User offline. Last seen 7 years 43 weeks ago. Offline
Joined: 30 Mar 2011

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!

---------------------------

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

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

1
2
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

lemsim
User offline. Last seen 7 years 43 weeks ago. Offline
Joined: 30 Mar 2011

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

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

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

lemsim
User offline. Last seen 7 years 43 weeks ago. Offline
Joined: 30 Mar 2011

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.

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

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

lemsim
User offline. Last seen 7 years 43 weeks ago. Offline
Joined: 30 Mar 2011

I will. Thank you very much.

Mo

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

You are welcome and thank you for your support.
-M.Y. Developers

lemsim
User offline. Last seen 7 years 43 weeks ago. Offline
Joined: 30 Mar 2011

Hey, me again!

I just wanted to drop a quick (hummm...) line to say THANK YOU!!!!!!!!!!! for suggesting I use the Physics engine instead of doing my own object display moves in "enterFrame" and collisions. WHAT a difference!

I not only used the physics to check for collisions but I also provide impulse, and torque the rocks (asteroids) so I do not even have to deal with that in my code.

Now the largest slice of time the Particle Candy process as you can see in this profiler output.

http://s8.postimage.org/6i7sx2gqt/profiler2.jpg

Simply amazing. Thank you again.

I have also couple questions if I may:

1- I noticed that the more I improved my game in term of performance (using physics for instance) the Particle Candy (PC) share of the 20 seconds profiles seems to have increase. Or at least it is now red. I am assuming it is normal...

2- As you can see on the graph above, the PC share seems to be around 80% graphically but the PC time shows only 12 seconds of the total 20 secs. Is it because you only display the top 10 slowest process?

4- Is the profiler works on a MAC as well? It does not work for me (Mac Mini, Lion, Safari) It works like a charm on my laptop PC (vista, Chrome)

3- The line 563 deals with deal with the virtual joystick I am using (in addition of the joystick.lua line 111 and line 43. It seems that when I move the joystick (moves a gun cross on the screen) The process takes the bulk of the process (after PC) I am using the following joystick.lua I found on the code page (byMatthew Pringle) :

http://developer.anscamobile.com/code/joystick

Right now I am assuming it is the stuff I am doing in the joystick phase (moving guncross,...) that slows things down a little. I am curious, did you see something like this in your own game since I believe you are using 2 joysticks! Maybe I am simply using an old joystick code..

In any event, I cannot thank you enough for pointing me in the right direction in term of the physics engine and the time share for the coding in enterframe.

Mo.

ps: Unfortunately, I did not have much time to look into the issue of not being able to display the code line (as you can on the graph above) since I was very busy this last few weeks converting my game for use with the physics engine. Now that it is done and I am back in profiling mode, I will look into the issue again report here.

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Lemsim,
No problem. The physics engine vs lua movement observation actually came from particle candy. We initially had it in such a way that the projectiles started off as non-physics which turned into physics objects when they were near another object. We ended up getting more FPS using pure physics than the other way around. Surprising yes but it makes sense b/c lua is a scripting language not a number crunching one.

As for your questions

I noticed that the more I improved my game in term of performance (using physics for instance) the Particle Candy (PC) share of the 20 seconds profiles seems to have increase.

yes this is correct. You have done a great job optimizing your code, there is no one section of your code that takes up a lot of time except external libraries. Are you using particle effects just for effects or for your game logic too. Beware, it was not designed to be used for game logic (experience talking).


As you can see on the graph above, the PC share seems to be around 80% graphically but the PC time shows only 12 seconds of the total 20 secs. Is it because you only display the top 10 slowest process?

this can be due to a few reasons.
1) yes we display the top 10 and there are no other hotspots in your code
2) Although profiler can look at some C functions that occur under the hood, it does not display the results because quite frankly there is nothing you can do to change it. If for instance the physics engine overhead is taking the rest of the 8 seconds then you will not see it in profiler. We will add the option for a "verbose" mode next update although there will be all sorts of wiered C functions that come up that arent documented that may be confusing.
3) It might be the case that corona is just idleing during that 8 seconds. if you are running at 30 fps then you have 33ms per frame to do stuff. if you run over this limit then your fps will drop. It could just be the case that your code is taking 80% of this time (like 24ms) and is idleing the other 20%. The best way to find out is run the code on the device with an fps profiler, if the framerate is 30 then you are in good shape.


4- Is the profiler works on a MAC as well? It does not work for me (Mac Mini, Lion, Safari) It works like a charm on my laptop PC (vista, Chrome)

Yes it works on mac. However due to security restrictions Mac does not allow us to launch the html file directly from corona. Rather you will have to navigate to your project sandbox document directory and open it. Once you have opened it you can just refresh the page to view a new profiler result.


The line 563 deals with deal with the virtual joystick I am using (in addition of the joystick.lua line 111 and line 43. It seems that when I move the joystick (moves a gun cross on the screen) The process takes the bulk of the process (after PC) I am using the following joystick.lua I found on the code page (byMatthew Pringle) :

are you sure about line 563? it only seems to go to 322. We never seemed to have a problem with the joystick code. Your code must be pretty optimized if that even shows up as one of your top 10 profiler results. Assuming you are only polling it once per frame and you are caching the result, you should have no problem. Beware that accessing x and y coordinates from any display object is more expensive than accessing a table value you created so you should cache this if you are using it multiple times.

Hope that helps and let us know if you have any more questions.
-M.Y. Developers

lemsim
User offline. Last seen 7 years 43 weeks ago. Offline
Joined: 30 Mar 2011

Thank you so much for the FAST response. I am so glad the profiler works on the MAC as well! I go back and forward between the pc and mac.

Yes I can see that everytime I use the joystick it shows high on the list of process. Frankly I am not surprise since I did not work on optimizing the code where the joystick is called. They are many things that I do when the player moves the joystick like moving a gun cross, updating a laser beam and so on.

Yes I learned that the hard way that accessing x and y coordinates from any display object is expensive. I am not completely sure about your suggestion to cache them? For instance I tried

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
local gunCross    = display.newImageRect (imagesPath.."gunCross.png",56,56)
gunCross.x = 240; gunCross.y = 160
 
..
..
 
-- then later
 
local function moveGunCross()
 
local gunCross = gunCross  --- this is the I cache the gunCross display object
 
gunCross.x = 240 +  dX*240
        
if gunCross.x <= 0 then gunCross.x = 0 end
if gunCross.x >= 480 then  gunCross.x = 480 end
 
...
....
 
 
end

Is this what you suggesting? The moveGunCross() is called everytime I touch and move the virtual joystick (joystick.onMove = moveGunCross)

In any event, the good news is your profiler! I can simply make a change and then run it right there and see where the bottlenecks are. No more guesses!

Thank you so much for a great product and an even greater support. I appreciate it very much.

Mo

PS: I am very curious about your question:

"Are you using particle effects just for effects or for your game logic too. Beware, it was not designed to be used for game logic (experience talking)"

I "think" I am using PC for effects (to show explosions when there is a collision between two bodies) What do you mean "PC was made for game logic"? I am wondering if you are talking about using the game logic to start and stop the PC update during the game? That will be great to update PC only an emitter is actual emitting particles. Not sure if that actually possible...

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Caching the X and Y values will help you alot and you can do it like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
local gunCross    = display.newImageRect (imagesPath.."gunCross.png",56,56)
gunCross.x = 240; gunCross.y = 160
 
..
..
 
-- then later
 
local function moveGunCross()
 
local gunCross = gunCross  --- this is the I cache the gunCross 
display object
 
gunCross.x = 240 +  dX*240
 
local gunCrossX, gunCrossY = gunCross.x, gunCross.y --this line is expensive so we cache these in a local variable so we dont have to access it again.
        
if gunCrossX <= 0 then gunCross.x = 0 end --use cached copy
if gunCrossX >= 480 then  gunCross.x = 480 end --use cached copy
 
...
....
 
 
end

as for the PC question. For space conquest we initially had PC taking care of spawning bullets and we used FX fields for rockets and stuff. This turned out to be a performance disaster. As long as you are using it only for effects then you should be fine. Just make sure to test consistently on the device.
-M.Y. Developers

lemsim
User offline. Last seen 7 years 43 weeks ago. Offline
Joined: 30 Mar 2011

Got it! Thank you so much. I understand about the PC and using it for other things than special effects. Fortunately I am only using it for explosions in my game and it seems to work great.

It is sooo much fun to use your profiler software to squeeze the last bit of performance out of my code! I need all the help I can get it since this is a fast pace game.

THANK YOU!

Mo

cyhiso
User offline. Last seen 8 years 9 weeks ago. Offline
Joined: 26 Feb 2011

Hi! Wanna thank you for a great job! Your Corona profiler helps me to improve the performance of my game dramatically!!! I started from using 22 sec from 25 on PC) and now it 0,8-1,5 sec from 25. SUPER PERFORMANCE BOOST!
And your advises to turn movement from incrementing x/y valuse per frame to physics are great too!
I have 2 questions:
1) - is it possible to launch profiler on the device?(i tried, but i get the page with only one block telling, that 25 sec test is passed..and no other info)
2) - when do you plan to make updates and to add opportunity to check overall performance(including physics)? cause even if i get 0,8 sec for 25 sec test..i have framedrops (from 60 to 54-56) that are noticable..and i think it can be cause by a lot of physics objects in the frame!

anyway, thank you for a great job! one of the most useful topic and tool ive ever seen on this forum!!!

producerism
User offline. Last seen 5 years 6 days ago. Offline
Joined: 31 Mar 2011

for $6.99 I couldn't resist. I'll be checking out how this helps my project. I was thinking of making a similar tool, so really looking forward to using it.

update: unfortunately, having problems. "WARNING: Cannot create path for resource file 'screenGame.lua' b/c it does not exist."

I noticed earlier in the thread you asked someone if they were using subdirectories. I am, and heavily rely on them to keep my code organized. Is there an issue with using the profiler along with subdirectories?

don
User offline. Last seen 6 years 32 weeks ago. Offline
Joined: 24 Jan 2011

Hi M.Y. Developers,

Can you give an example of switching over from lua to using the physics engine for updating movement of objects? I have a boids simulation that I've sped up with your profiler, and I'm wondering if what your suggesting with the physics engine can be applied to it to further speed things up. I already using the caching technique and the translate, rotate, scale functions to speed things up, but I'm wondering if it can go even faster.

Thanks.

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Cyhiso,
Thank you for your input, it is much appreciated.
Now to address your questions
1) no it is currently not possible to profile on the device because in order to display the lines we need access to the LUA source code files. Unfortunately these are not available as resource files on the actual device for security purposes, you probably don't want to be publishing your code on the app store. If there is popular demand we can look into on device profiling, but it will not be as automated as the desktop profiling (ie it will be more intrusive in your code)

2) expect an update either tomorrow or the day after

Thanks for the support,
M.Y. Developers

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Producerism,
Sorry for the delay we have been doing some holiday traveling. We are working on the issue and you will have a fix tomorrow or the day after. The problem arises because LUA does not give us the function names, instead it gives us a LUA filename and a linenumber so we must read the lua files directly. We did not rely on placing code in subdirectories so this problem never came up during testing. Our apologies and we will get this fixed asap.
Thanks,
M.Y. Developers

M.Y.developers
User offline. Last seen 4 years 18 weeks ago. Offline
Joined: 24 Apr 2011

Don,
The lesson we learned is: use as little lua code as possible. For instance instead of using a translate() every frame like this

1
2
3
4
5
local vx, vy, vr = 10,2
function enterframe(e)
  myObj:translate(vx,vy)
  myObj:rotate(vr)
end

the code above is more efficient than reading and setting parameters directly but a speedier way would be to turn it into physics objects so the only lua code you need would be during initialization

1
2
3
physics.addBody(myObj)
myObj:setLinearVelocity(vx,vy)
myObj.angularVelicity = vr

this will in effect do the above code segment but with less lua code. Sorry if there are errors but this is how you could do it.

Thank you and let us know if you have any other questions,
M.Y. Developers

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.