Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why does reflection slow down android phone

I read many times that reflection will slow down the phone performance. How true is this?

For example in my case, I get some parameters from a web service which have the same name as the parameters of a class I have in my android app. so I just set the values of these parameters using java fields and reflection... it doesn't seem to slow down the performance..

can anybody explain to me the fact behind this idea about reflection slowing down performance?

like image 688
ccot Avatar asked Dec 21 '22 16:12

ccot


1 Answers

Take a look at this question. Basically, you are getting outside of the optimizations that the compiler can perform because reflection happens dynamically.

If you're not making a lot of reflection calls (e.g., it would be bad to do inside the getView of a ListView), you can probably get away with it. It's there to be used, just be judicious about it.

like image 124
Brian Cooley Avatar answered Jan 12 '23 16:01

Brian Cooley