Check the Status
Optimizing for power consumption isn't always important. In a server it's important only at times of heavy load, and in a mobile device it's important only when on battery power.
All mobile operating systems provide mechanisms for checking the power status. On a BSD derivative, including the iOS, it's a trivial check of a sysctl(). Under Linux, it requires a massive blob of library code, because the kernel is useless at providing a consistent hardware-independent interface.
Either way, it's worth checking. For example, consider a mobile email client. As a user, you might want to search for a specific email message while on the go. The app can either iterate through every single message to run the search, or it can check an index. Checking the index is faster and uses a lot less power, because it has both lower CPU and I/O requirements. But building the index uses a lot of power. A well-designed application would update the index whenever it detected that the unit was plugged in; then the app would use the index while mobile, with a simple search over the few email messages that arrived since the unit was unplugged.
Often you'll find that work can be deferred until later. Before you do anything that will cause a lot of load, check the power status. If you're running under battery power, leave that work until later.