what is best way to check a code is more effiecient and runs faster than others

Started by
11 comments, last by Sacaldur 8 years, 9 months ago
Advertisement
In addition to the wonderful advice given above (and certainly not 'instead of') I like to also take a look at the disassembly. Its not a tool for everyone, but I find there are times where knowing what actually the compiler spit out has helped me clean up a few inner loops here or there.

In addition to the wonderful advice given above (and certainly not 'instead of') I like to also take a look at the disassembly. Its not a tool for everyone, but I find there are times where knowing what actually the compiler spit out has helped me clean up a few inner loops here or there.

The dissassembler might be your most powerful tool when it comes to JIT compiler languages, it is complicated, though, if you never have done anything on that field.

The problem with those languages is that they do not just compile your code just in time but they also profile your code on the run and change or remove parts of it "statistically".

If you profile your program running with one of those languages you might notice that the same methods change in speed every so often because the JIT i.e. notices that a part of your code is dead or that your if-else condition is only met in 1% of all occasions and removes it (not completly of course) or caches the other condition.

Dissassemblers can help you understand what exactly the JIT compiler has done with your code and help to make your code work 'with' it (easier).

However, this not only needs experience on that field but you also need to understand how exactly your JIT compiler works.

One of the worst or best (this is very arguable from different viewpoints) languages is Java on that field, C# is comparable also when considering NGEN in.

My suggestion is still to use a profiler because no matter what it will always be your first step to find bottlenecks at all before can analyse them

well. thank you all my friends.

can you suggest some profiler program that works well with c# code as i work with it as unity script right now. im searching for best free one. i found redgate that looked sophisticated but not free. and prof it and some other ones. i searched alittle in internet and stackoverflow and i found many people use timers like timestap and stopwatch as their timer performance analizer. maybe its not the best way but maybe a simple fast way.

By "i work with it as unity script" you mean you're using C# as scripting language in Unity, right? "UnityScript" is what the guys behind Unity call "JavaScript", without actually being JavaScript.
Then you should just take a look at the Unity Profiler first. I guess it's available for free, now that Unity 5 contains all engine features in the "personal edition" (in the free version).
Including any other profilers could be troublesome, since you don't have a Visual Studio solution to run the entire code yourself.

This topic is closed to new replies.

Advertisement