I'm using python 3 for my flask app which is running in a port 5000. It has one sample API. I need to profile memory, CPU usage while hitting this API from REST or Browser.
Please help me out for better solution.
import logging
from flask import Flask, jsonify
from flask_cors import CORS
logger = logging.getLogger()
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - "
"%(name)s:%(lineno)d [-] %(funcName)s- %(message)s")
logger.setLevel(logging.INFO)
app = Flask(__name__)
app.url_map.strict_slashes = False
CORS(app)
def health_check():
return jsonify({"message": "success"})
app.add_url_rule(rule='/health', endpoint='health-check',
view_func=health_check, methods=['GET'])
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)
How about (see: https://pypi.org/project/memory_profiler/) :
Gives: