Re: [android-developers] Re: C/C++ struct in android
On Thu, Nov 24, 2011 at 8:44 PM, Lew lewbl...@gmail.com wrote: Bret Foreman wrote: If the OP is really concerned about performance he can create an array of objects and implement his own protocol for reusing them. Then after the initial creation of the array, no objects need to be either created or destroyed. This might or might not have any effect on performance, much less a noticeable one. The OP has shared no evidence that they have a performance problem, related to GC or otherwise. There is no evidence that your approach would help, because changing the lifetime of objects influences GC in sometimes unexpected ways. Even if the array approach did shave of a few milliseconds here or there, the added complexity of manually taking over memory management could create slowdowns and likely would create errors, and the effect on overall application performance would still be negligible. If the OP is really concerned about performance, and willing to behave like an intelligent person, he can *measure* the app's performance under realistic conditions, *profile* it and determine where the inefficient spots are *before* and *instead of* engaging cargo-cult superstitions about what will help. Maybe I didn't explain myself very clear, sorry for this and for my english, as this is not my first language. So, I'll try to clarify myself, as I am being addressed as stupid (not like that, but saying things like willing to behave like an intelligent person implies that I'm not behaving like one): I have not started the developed of that part of the application, so I can't measure or profile the performance. I was first doing a bit of research, to try to do things as they should be done, from the beginning, not start doing thins randomly, and then try to improve the results. So I came here to ask for possible solutions I might not know (as I know I'm not an expert, not in Java and not in Android). My first idea was to do it as all of you suggested, by using objets (classes for structs). But I read on android webpage (see the link I shared before) that we should avoid creating objets when possible. So, as I don't know any other means of doing this without creating objects, I came here, to ask if there was another way of doing this in android, that I'm not aware of. So, I'll start creating classes, as suggested, and If find some performance problems, I'll try the alternative ways suggested here. Thanks to everyone for your help and time ^_^ Best regards! If you double the speed of something that only took 0.01% of overall execution time, but you have tripled the maintenance costs for the whole app and added new bugs that require new fixes, how is that a win? -- Lew -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- --- http://aitorTheRed.blogspot.com http://www.last.fm/user/aitorTheRed/ -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: C/C++ struct in android
If the OP is really concerned about performance he can create an array of objects and implement his own protocol for reusing them. Then after the initial creation of the array, no objects need to be either created or destroyed. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: C/C++ struct in android
Bret Foreman wrote: If the OP is really concerned about performance he can create an array of objects and implement his own protocol for reusing them. Then after the initial creation of the array, no objects need to be either created or destroyed. This might or might not have any effect on performance, much less a noticeable one. The OP has shared no evidence that they have a performance problem, related to GC or otherwise. There is no evidence that your approach would help, because changing the lifetime of objects influences GC in sometimes unexpected ways. Even if the array approach did shave of a few milliseconds here or there, the added complexity of manually taking over memory management could create slowdowns and likely would create errors, and the effect on overall application performance would still be negligible. If the OP is really concerned about performance, and willing to behave like an intelligent person, he can *measure* the app's performance under realistic conditions, *profile* it and determine where the inefficient spots are *before* and *instead of* engaging cargo-cult superstitions about what will help. If you double the speed of something that only took 0.01% of overall execution time, but you have tripled the maintenance costs for the whole app and added new bugs that require new fixes, how is that a win? -- Lew -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: C/C++ struct in android
On Thu, Nov 24, 2011 at 2:44 PM, Lew lewbl...@gmail.com wrote: Bret Foreman wrote: If the OP is really concerned about performance he can create an array of objects and implement his own protocol for reusing them. Then after the initial creation of the array, no objects need to be either created or destroyed. This might or might not have any effect on performance, much less a noticeable one. The OP has shared no evidence that they have a performance problem, related to GC or otherwise. There is no evidence that your approach would help, because changing the lifetime of objects influences GC in sometimes unexpected ways. Even if the array approach did shave of a few milliseconds here or there, the added complexity of manually taking over memory management could create slowdowns and likely would create errors, and the effect on overall application performance would still be negligible. If the OP is really concerned about performance, and willing to behave like an intelligent person, he can *measure* the app's performance under realistic conditions, *profile* it and determine where the inefficient spots are *before* and *instead of* engaging cargo-cult superstitions about what will help. If you double the speed of something that only took 0.01% of overall execution time, but you have tripled the maintenance costs for the whole app and added new bugs that require new fixes, how is that a win? -- Lew But the whole point is moot: the vm optimizes things beyond what you would think. If you want to know the optimizations that the vm makes, you can read about it, and unless you do investigate it there's not point in worrying about it. (For example, the vm cuts out functions with no effects, think Object constructor, does jit compilation, etc...) So until you investigate the details, or have profiled and found a problem, there's not really any point in worrying about it. kris -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: C/C++ struct in android
On Nov 24, 11:44 am, Lew lewbl...@gmail.com wrote: Bret Foreman wrote: If the OP is really concerned about performance he can create an array of objects and implement his own protocol for reusing them. Then after the initial creation of the array, no objects need to be either created or destroyed. This might or might not have any effect on performance, much less a noticeable one. The OP has shared no evidence that they have a performance problem, related to GC or otherwise. There is no evidence that your approach would help, because changing the lifetime of objects influences GC in sometimes unexpected ways. Actually, I learned this approach from studying the Android internals, specifically the way the ListManager and ListAdapter work. I applied it to some code that I was using to manage a couple hundred objects and it worked like a champ. I did profile my code before and after, just as you are suggesting to the OP, and I saw a 10X improvement in that code section. You have a good point, though, without profiling first, you don't really know where the problem lies or how much a particular change has helped. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en