Profile cover photo
Profile photo
Billy Ng
Communities and Collections
View all

Add a comment...

Just making a post in new google plus (nothingtodohere)
Add a comment...

Post has attachment
Add a comment...

Post has shared content
read the comments
I really like this article on the importance of thinking about performance during development, instead of ignoring it completely with the excuse of "premature optimization."

This is especially relevant for mobile development: performance issues that users don't even see can have negative impact on things like battery life; the resource requirements of our code has a direct impact on the hardware it requires to run well, which can completely push the product out of large markets; and user's expectations of the responsiveness of mobile applications tends to be higher than desktop applications even though they are running on slower more constrained hardware and often with much higher-resolution screens.

My own feeling on this is that as a professional software engineer, part of our job is to understand the actual trade-offs we are making during implementation.  There are many things you can do that will be significantly more expensive than other options, which really aren't worth whatever small advantages they provide.  Integral to being proficient at a language, framework, or platform is having a general understanding of the relative efficiency of the various ways you use it so that you can use that knowledge as part of the decision making process throughout development -- from design through implementation and maintenance.  That is not "premature optimization," that is making good use of your tools.

Another way to look at it is this: the hardware you are running on has a fixed amount of resources; when you are implementing your code, you are deciding how to make use of those resources.  Every decision you make that favors other things over efficient use of those resources is also a decision that is limiting the number of features you can deliver to your users, because those resources are no longer available to deliver features.  Of course this doesn't mean you should micro-optimize everything you do, but you also shouldn't ignore efficiency at all -- you need to understand the trade-offs you are making to create the best product for your users.  If you don't, there is a good chance another developer will make better decisions, and be able to developer a superior product that is able to deliver more or better features because they have a more efficient implementation without really sacrificing their productivity.

For example, there are a lot of things in the Java language that can lead to significantly less efficient results than other equally viable approaches.  Selecting between a standard or enhanced for loop can have a 3x difference in performance when iterating over an ArrayList; Java enums are tremendously more expensive in code size than simple static final ints; classes and objects have not-insignificant overhead, so if you take a very class-heavy approach to your implementation you can end up with a significantly larger code size and RAM footprint for your app.

All of these are things that you decide throughout the implementation of your app, but are very hard to fix later on.  This is not the kind of stuff you can throw under a profiler and see, "oh here is the hot spot in these 100 lines of code" and spend a day optimizing that.  Instead what you end up with is pervasive small performance problems throughout your entire app that add up to a large problem, for which a profiler will either not reveal any clear indication of a problem at all (because it is everywhere), or you will end up in an "oh sh*t" moment where you realize that fixing your performance problems are going to require changes all through your code base.

One experience that will always stick with me was when I was working at a previous company on a mobile operating system.  We had spent a few years working on it, had the system up and running on reference hardware, but were not happy with the performance we were getting.  We did a lot of profiling, trying to find what was causing it to be slow, but couldn't find anything significant.  Finally in desperation we went to the hardware manufacturer and asked if they could help out.

The answer we got back from them: "you are running too much code."  Out first reaction was, wtf, of course there is too much stuff being done, but what is it?  But the problem wasn't that there was some specific parts of the platform that needed optimization, it was that just generally all over the place the implementation was too expensive for the hardware it was running on.  It was blowing out the CPU caches all over the place, needing too many instructions given the speed of the CPU, etc.  Fixing such issues requires tremendous work across the code-base reworking how every little thing is implemented to get rid of overhead.  It is lots of steps of find 1% here, .5% there, and on and on, until you either run out of time or you eventually decide "good enough."  It is not a situation you want to be in at the end of your product development.

Our Android documentation has a lot of information on these topics for both Java and the Android framework that every Android developer should have a good understanding of:
Add a comment...

Post has shared content
Espresso 2.0 is here!

A release is never too late, nor is it too early. It arrives precisely when it’s meant to.” That being said, we would like to apologize for such a long wait. Part of the delay was caused by work that ensures that this does not happen again.

Espresso 2.0 is packed with new features[0], but perhaps the most important change is that Espresso is now part of the Android Support Library and available in the Android Open Source Project (AOSP) soon. This will make it easier for you to contribute to future releases.

With this release, we would also like to introduce the new AndroidJUnitRunner[1], which contains all the functionality of GoogleInstrumentationTestRunner and adds extra features[2], including Junit4 support.

Although this is an API-breaking release (hence the major version bump), we do not expect the majority of projects to be affected by anything other than the package name change.

We have added a new set of individual sample projects, available on GitHub[3], to make it easier for you to learn about the new features and get started with Espresso.

Documentation[4,5] and Javadocs[6,7,8] are still hosted on android-test-kit, but will move to in early 2015.

We hope that you enjoy the new Espresso experience and look forward to your feedback and contributions.

Happy holidays and happy testing!

#androiddev  #androidTesting

[0] Release Notes -
[1] AndoidJUnitRunner Javadoc -
[2] AndroidJUnitRunner Docs -
[3] Android-Testing Github Samples -
[4] Espresso Setup Guide -
[5] Espresso Documentation -
[6] Espresso-Core Javadoc -
[7] Espresso-Contrib Javadoc -
[8] Espresso-Idling Javadoc -
Add a comment...

Post has shared content
Add a comment...

Post has shared content
Add a comment...

Post has shared content

if I have several library projects using support-v4, what is the best practice for my repository setup so I dont need to update build.gradle of each project everytime support-v4 updated? 

Post has shared content
Probably one of the best feature in the upcoming beta 2 of #AndroidStudio : A new view which flattens all folders into one structure and shows you all different versions of the same file.

Thank you +Android Developers Tools Team! 

See the whole session from #io14  about the current state and the look out here: Google I/O 2014 - What's new in Android development tools

Add a comment...
Wait while more posts are being loaded