Reputation: 1253
I have a method that draws tiles onto the screen, and inside this method there is a call to a method in the same class called drawFloor which draws specific tiles.
In the external method, I started a stop watch right above the drawFloor call and stopped it right below the call, and the time I got was 2.4 milliseconds.
Then I put the stop watch inside the actual drawFloor method itself, making the stopwatch embody all the code in the method, and the time I got was 1.9 milliseconds.
The only thing that I think could be making this change in time is the passing of parameters, and I don't understand why it's so expensive. It only passes two parameters, one to a custom class called "camera" and also a sprite batch.
Upvotes: 0
Views: 328
Reputation: 1501003
No, it's really not that expensive. It's almost certainly just a discrepancy in your measurements. Good micro-benchmarking is hard; it's entirely possible that you've done something else which changes things, or perhaps your machine is just less busy doing other things.
Method calls and parameter passing are not expensive - certainly not to the tune of half a millisecond.
Upvotes: 8