Skip to main content

Course 2

Understanding Slowness

Slow Web Server

ab - Apache benchmark tool

ab -n 500 site.example.com

Profiling - Improving the code

Profiling 可透過監控和分析即時資源使用情況,協助軟體工程師設計高效率且有效的應用程式。對 IT 專業人員而言,Profile 的能力是非常寶貴的工具。雖然 Profiling 並非新技術,但類似技術在今日仍然適用,而且 Profiling 可改善反應速度並最佳化資源使用,為軟體開發奠定穩固的基礎

A profiler is a tool that measures the resources that our code is using, giving us a better understanding of what's going on.

  • gprof : For C program
  • cProfile : For Python program
  • pprofile3 + kcachegrind(GUI) : For Python program
  • Flat, Call-graph, and Input-sensitive are integral to debugging
  • timeit (python module) : Measure execution time of small code snippets

Parallelizing operations

Python modules

  • threading
  • AsyncIOasyncio