官术网_书友最值得收藏!

Performance – meaning and key metrics

There are two key characteristics of code:

  • Code quality: It has to be solid and flexible and have a good architecture
  • Code performance: It has to be fast

Making the code architecture very solid and stable is the most important task, but we shouldn't forget about making it fast as well. Achieving high performance can be a tricky and dangerous task. Here are a few things that you should keep in mind while working on performance improvement:

  • Don't optimize your code upfront

    There are many articles about this topic, why it's dangerous, and why you shouldn't do it. Just don't do it, and as Donald Knut says:

    "Premature optimization is the root of all evil"

  • Measure first

    Firstly, don't optimize upfront, and secondly, measure first. Measure the code's performance characteristics and optimize only those parts that are slow. Almost 95 percent of code doesn't require performance optimization.

    I totally agree with these points, but there is another type of performance optimization that we should think of upfront.

Everyday code performance

The small decisions that we make every day include the following:

  • What type should it be, Int or String?
  • Should I create a new class for a new functionality or add to an existing one?
  • Use an array? Or maybe a set?

It seems as if these don't have any impact on the application's performance, and in most cases, they don't. However, making the right decision not only improves an application's speed, but also makes it more stable. This gives higher performance in application development. The small changes that we make every day make a big impact at the end of the year.

The importance of performance

High performance is very crucial. The performance of an app is directly related to user experience. Users want to get results immediately; they don't want to wait for the view to load, see a long Loading indicator, or see a lagging animation.

Every year, our computers and devices become more and more powerful, with more CPU speed, memory, storage, and storage speed. Performance problems could seem irrelevant because of this, but the software complexity increases as well. We have more complex data to store and process. We need to show animations and do a lot of other things.

The first way of solving a performance problem is by adding more power. We can add more servers to handle data, but we can't update our clients' PC and mobile devices. Also, adding more power doesn't solve the code performance issue itself, but just delays it for some time.

The second, and correct, solution is to remove the issue that causes the performance problem. For that, we need to identify the problem, the slow piece of the code, and improve it.

The key metrics

There are many things that impact an application's performance and user experience. We will cover the following key metrics:

  • Operations' performance speed
  • Memory usage
  • Disk space usage

The most important of these and the one that has the biggest impact is the operations' performance speed. It tells us how fast a particular task can be performed, for example, creating a new user, reading from a file, downloading an image, searching for a person with a particular name, and so on.

主站蜘蛛池模板: 个旧市| 岳池县| 瑞金市| 抚松县| 房产| 西平县| 二连浩特市| 吉木萨尔县| 垣曲县| 宿迁市| 兖州市| 安溪县| 惠安县| 嘉定区| 定安县| 怀来县| 双江| 湖口县| 鸡泽县| 沙湾县| 河东区| 治县。| 郧西县| 弥渡县| 富宁县| 新田县| 安仁县| 庄浪县| 黎城县| 来安县| 汤原县| 淮滨县| 稷山县| 亳州市| 荣昌县| 镇巴县| 冷水江市| 平遥县| 泽州县| 馆陶县| 射洪县|