Home  >  Article  >  Java  >  In-depth understanding of how to improve APP performance summary

In-depth understanding of how to improve APP performance summary

ringa_lee
ringa_leeOriginal
2017-09-17 10:19:491486browse

Abstract: This article comprehensively introduces how to improve the performance of mobile apps from aspects such as optimizing the size of mobile apps, app API design, architecture design, adaptive display, quick startup, etc. The following is the translation.

In-depth understanding of how to improve APP performance summary
Last year, on the flight back from London, I met a person who was engaged in the mobile phone industry. For the past 20 years, he has been responsible for the adoption of new technologies in a large company that can be called a leading company.

During the 8 hours of our flight together, I have been thinking about some of the things he mentioned. He believes that mobile applications and their performance just keep being delivered. In fact, he can't even audit the performance of mobile applications to see how much significant improvements they have made.

After I landed in San Francisco, I contacted more people in the mobile phone industry to learn about this matter, and found that they all had similar views. Code quality and basic framework are the only things everyone discusses.

I immediately thought about how to build apps on Simform, to explore some very good practices, follow these practices, establish benchmarks, and break through existing applications, which can reach billions of dollars in scale.

The following factors will greatly affect the quality of mobile applications:

  • App size

  • App performance

  • Guidelines for the specified platform

  • Architectural design

Now, let’s see how to optimize them in a simple way with easy-to-adopt steps to make mobile apps faster.

Minimize application size

Mobile phones do not have powerful GPUs, however, low-end configuration phones occupy the majority of the Android market share. They don't even support 2G or 3G, and downloading a large application that you need immediately would be a nightmare for users. On such a low-end phone, the less space an app takes up, the better.
In-depth understanding of how to improve APP performance summary

Optimize the network

Text first, images second

Optimize the network, try loading text data first. Image-based content displays within the application can then be loaded asynchronously.

Avoid duplicate network requests

Those familiar Volley apps on Android will know more about this request. When the application performs poorly, the Android application can use Volley to send two requests to the server at the same time. You can delete one request and the request will be deleted, but the application's response will be that there is no such request. Not just a functionality issue, duplicate requests also increase system congestion and degrade application performance, especially when there are millions of application users. Imagine that if the number of requests is doubled, the number of servers will be doubled. Then when you want to reduce costs, you will be very desperate.

Understand and make adjustments based on connection quality

Suppose an application needs to decide whether it is available based on network conditions. Applications can change the quality of content delivered based on the network conditions the user is currently in, ensuring that application usage does not fail.

Effective API Design

The way an API is designed will have a huge impact on application performance. An incomplete or lazy API design will increase the burden on the application. Workarounds on the API often put too much strain on the limitations of the network.

Design the API load of the mobile application to ensure that the application has the following characteristics:

  • Consistency: Developers should know the expectations and there is no wiggle room when it comes to designing API consistency.

  • Completeness: Has a simplified solution.

In-depth understanding of how to improve APP performance summary

Starting from the UI and all the way to the data is a great way to design an API load with consistency and completeness, thereby improving the performance of your application. Don't send all requests to the API from your phone, only those that are actually needed.

Optimize images in your app

To optimize images in your app, you can:

  • Use vector images

  • Provide dynamically sized images

  • Use color filters instead of using Different color image sets

  • Use image caching

  • Use libraries like Picasso and Fresco

Cache data for offline optimization

When the network is poor, all the data you have obtained will be displayed while obtaining the data. Doing this will:

  • Reduce server load

  • Reduce the number of mobile phone radio usage and reduce the power consumption of mobile Apps

If you don’t have a testing team at your disposal, you can try switching your phone to Airplane mode to test the offline performance of your application.

Make sure apps fit the size of your phone’s screen

There’s a lot of discussion that’s been brought up about screen size, and Android gets some big attention because there are literally thousands of devices out there, each with own resolution and screen size.

As the best strategy:

  • Build

  • Optimize MDPI and HDPI for small and medium screens

  • Achieve adaptive UI flow

In-depth understanding of how to improve APP performance summary

Don’t have hundreds of devices to test resolution and screen size? Test with emulator configuration.

Memory usage in Android

In order to provide mobile phone users with the ability to multitask, Android sets limits on how much memory each application uses. These limits are not static and increase or decrease with the number of mobile applications. And changing.

Consider RAM limitations throughout the application development process, as well as the fact that applications running in the background will take up unnecessary resources.

However, you can optimize the application by the following means:

  • Limit the validity period of the service, consider using intent service to limit the life of the service

  • When the user switches to a different interface, release UI resources

  • Use memory-efficient code architecture

  • Minimize the use of external libraries

How fast does the app launch?

Average top 25 apps on PlayStore with launch times ranging from 800ms to 4.5s. Now, 4.5S is too much for most use cases.

The bottom line is, the app needs to launch quickly!

To optimize the startup time of your iOS application, you should consider the following:

  • Embed a small number of dylibs

  • Merge Objective-C classes

  • Eliminate static initialization software

  • Use more In Swift, Apple recommends

  • Use DYLD_PRINT_STATISTICS to measure results

  • Avoid using dlopen()

In Android, the following situations usually affect app startup time:

  • View instantiation

  • High resource consumption content such as decoding bitmaps

  • Running layout

Make apps launch faster in Android:

  • Don’t show parts of the UI you don’t need on first launch, use hierarchy placeholders that you can show later

  • Avoid chaos due to memory allocation and do garbage collection as much as possible

  • Use tools like Apteligent to monitor and optimize application startup time

  • Avoid initialization code in application objects

  • Note Live, a recently launched app, this first launched app will behave differently.

Reduce device wake-ups

Frequently waking up your phone will significantly reduce system performance. This consumes system resources. You can limit the wake intents that your application will respond to.

Consider low-end Android phones

Not all Android users have the latest 2G+ memory phones. When we look at available Android devices, we see a high breakdown in terms of device capabilities.

When most developers develop and optimize applications to improve performance, they make a big mistake. They optimize their apps for the wrong devices, often with high-end devices available for testing.

A good rule of thumb is that there should be a variety of devices used to optimize app performance. This way, developers can cross-test.

  • Various speeds

  • Interface and resolution

  • Low memory

Smooth frame rate

On iOS and Android, the maximum frame rate for showing animations and gestures is 60fps .

If the frame rate is lower than 60fps, users will usually feel stuck.

In order to achieve a frame rate of 16ms (equivalent to 60fps), the code used for display in the application needs to be executed within 16ms. This is where you'll notice in Android, how expensive 5ms of garbage collection time is.

Let’s evaluate how this will impact end users. When you miss the 16ms limit, you'll often get a slightly lower frame rate of ~59fps. No big deal, right?

Wrong!

The reality is that if the application misses the 16ms limit once, it cannot use the window for the same frame and has to wait for the next frame.

Although the application only took 19ms to display, it missed the display window and the time displayed to the user became twice as long. You know, this way, users will think that the application is super bad.

Recover User Data on New Devices

Users often spend a lot of time setting up apps on their phones so that they work the way they want. When reinstalling an application, most users expect their original settings to remain available.

Saving configuration data helps improve application quality:

  • Any configuration modified by the user

  • Push settings notification

  • If the user has seen the welcome screen and introduction on the new screen

Discover potential consumption

Move from the application It is important to eliminate potential problems. Potential problems can cause application errors and often break the entire application. Statistics show that if an application runs slowly, more than 50% of users will uninstall the application within 24 hours.

Effectively handle potential related issues:

When network conditions are poor, you can limit third-party sources of potential problem factors

Reduce the need to use potentially consuming APIs on your phone

Optimize iOS applications Program to handle multitasking

Suppose there is a user using your application. The application will display well at 60fps and complete all the work in 9ms. As shown in the picture below:
In-depth understanding of how to improve APP performance summary

Now, when the user opens the second application on the phone, it also takes about 7ms to complete all the work. It now looks like the following picture:
In-depth understanding of how to improve APP performance summary

You can see that in order to display at a frame rate of 60fps, the two applications combined took 16ms.

Suppose the user opens another application at a frame rate of 60fps, and the work is completed in 10ms. The current time is 9+7+10=26ms, which means that the application's demo frame rate is 40fps instead of 60fps.

In-depth understanding of how to improve APP performance summary
Users of the app began to notice lags in the program, and almost the same thing happened with the GPU and memory.

Remember when apps kept crashing?

Okay, let’s take a look at the scenario of an application running on the device.

Now, introducing another application into the scene, we are still doing well and still have some memory left.

When we introduce another application into the scene, the system has no memory to allocate. The system will kill a process to free up resources.

This is why app development is so challenging (for those who really care about it)

Solving these challenges requires a little understanding of the iOS ecosystem. Let’s see how you can optimize your application for multitasking:

  • You can use tools to identify and fix bugs

  • Prioritize your work properly and don’t block the main thread

  • Identify and manage your toolset

  • Use caching and respond to memory alerts

  • Use the virtual memory system to increase memory recycling

  • Make trade-offs

If anyone can follow 50% of this, they will find that the performance of the application has improved A big improvement.

The above is the detailed content of In-depth understanding of how to improve APP performance summary. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn