How to do “performance-based” (benchmark) unit testing in Python

后端 未结 4 996
粉色の甜心
粉色の甜心 2021-02-03 12:48

Let\'s say that I\'ve got my code base to as high a degree of unit test coverage as makes sense. (Beyond a certain point, increasing coverage doesn\'t have a good ROI.)

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-03 12:51

    When I do performance testing, I generally have a test suite of data inputs, and measure how long it takes the program to process each one.

    You can log the performance on a daily or weekly basis, but I don't find it particularly useful to worry about performance until all the functionality is implemented.

    If performance is too poor, then I break out cProfile, run it with the same data inputs, and try to see where the bottlenecks are.

提交回复
热议问题