What’s a good way to find bottlenecks in code? I tried setting a start time value at the beginning of the functions in question and then finding elapsed time at the end, but I’m getting times in the order of 1e-10. This would be wonderful, but when I am actually executing the functions in question, the elapsed time from start to finish of all three is about 3 seconds by my watch. Something isn’t jiving, and the 3 second delay is prohibitively long. What is an effective way to determine which function is sucking up the time and then which aspect of the function is the problem?
profile each function on its own.
One is obviously looping for a long time or has a yield in so it has to wait for something to happen (or you load something large. as all loading means waiting for the coroutine in question, that can cause that too)
That’s what I’m asking. What’s a good method to profile? I was profiling each function individually, but, using my method, they all generated very small values which couldn’t possibly add up to 3 secs. I’m assuming I am not profiling correctly.
You could be starting time, calling the function, and then getting the end time. Calling a function never takes the time for the function to finish unless you wait for it to finish.
A better test would be to put the start timer inside the function as the first line and the end timer inside the function as the last line.
…or wait a bit for Unity 2.6, which will have a Profiler!