python - 使用 Django 单元测试进行自动基准测试

标签 python django api rest benchmarking

我有一个以 API 风格构建的 Django 应用程序,我需要对其进行基准测试。 我想使用 django unitetesting 库来构建 becnhmarks 作为 API 端点的测试。他们将使用 Django-test-client 查询端点并收集有关 SQL 查询及其时间的数据,并将其保存在某个地方。

这是明智的想法吗? 我还想查看带有堆栈跟踪的 Python 代码的计时,并查看哪些代码导致哪些 SQL 查询。有人知道在不修改应用程序代码的情况下收集此类信息的方法吗?

最佳答案

只是一个选项,我以前用过:nose它是 --with-xunit插件:

This plugin provides test results in the standard XUnit XML format.

在测试结果中,您将看到每个测试用例的运行时间、失败的堆栈跟踪等。

此外,django-debug-toolbardjango database logging可能会帮助您获取有关 SQL 查询的数据。

这里还有其他建议:

希望对您有所帮助。

关于python - 使用 Django 单元测试进行自动基准测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18450923/

相关文章:

python - django 迁移时出错 : "There is no unique constraint matching given keys for referenced table

php - AngularJS 和 PHP 后端

python - 在 FastAPI 中上传多部分形式的图像作为数据

python - 将变量传递给某些 if 语句(共享范围)

python - django-rest-framework "AttributeError: ' 函数'对象没有属性 'get_extra_actions' ”

javascript - 如何向外部 API 发出 GET 和 POST 请求?

api - 什么是 Telegram 聊天内存空间限制?

python - 如何在不指定完整路径的情况下可移植地运行 Python 脚本

python - 导入错误:没有名为 Tkinter 的模块(使用 NotePad++ 的 NppExec 运行 python)

python - TypeError 无法 pickle 函数对象(Django 缓存)