开发工具

社会公共资源下载站点

其他

接口性能分析

java 性能分析

  1. 启动 math-game
  • math-game是一个简单的程序,每隔一秒生成一个随机数,再执行质因数分解,并打印出分解结果。
  • arthas-github
    1
    2
    curl -O https://arthas.aliyun.com/math-game.jar
    java -jar math-game.jar

python 性能分析

PySnooper

flask 案例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from flask import Flask
import pysnooper

app = Flask(__name__)

@app.route('/double', methods=['POST'])
@pysnooper.snoop()
def double_numbers():
numbers = request.json['numbers']
doubled_numbers = []

for num in numbers:
doubled_num = num * 2
doubled_numbers.append(doubled_num)

return jsonify(doubled_numbers)
  • 接口测试
    1
    curl -X POST -H "Content-Type: application/json" -d '{"numbers":[1,2,3]}' http://localhost:5000/double
  • 结果
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Starting var:.. numbers = [1, 2, 3] 
    15:42:04.345209 call 8 @app.route('/double', methods=['POST'])
    15:42:04.345385 line 9 @pysnooper.snoop()
    15:42:04.345441 line 10 def double_numbers():
    15:42:04.345500 line 11 numbers = request.json['numbers']
    15:42:04.345543 line 12 doubled_numbers = []
    New var:....... doubled_numbers = []
    15:42:04.345595 line 14 for num in numbers:
    Starting var:.. num = 1
    # 省略部分输出
    Ending var:.... doubled_numbers = [2, 4, 6]
    15:42:04.345963 return 17 return jsonify(doubled_numbers)