有没有一个图书馆来基准我的Django应用程序的SQL请求? [英] Is there a library to benchmark my Django App for SQL requests?
问题描述
select_related
,更聪明的查询等)来提高性能。我想能够衡量改善,因为我一直在鼓励我,并能够说多少脂肪被修剪。我有一个很大的django单元测试,这个应用程序触摸了代码的很多部分。 有些库/程序/脚本可以运行单元测试,然后打印出总共执行了多少个SQL请求?这样我可以迭代地改进我们的应用程序。
此信息仅在调试模式下可用。我不知道任何图书馆做你正在努力做的事情,但是你可能很容易地装载一些东西。
如果你正在运行调试模式,那么您可以查看使用 connection.queries
运行的所有查询。这实际上是django调试工具栏的工作原理。
所以改变你的unittests来看看connection.queries dict,这应该让你开始很好。 >
I have a large complex Django App that we use that does lots of things. From looking at the Django Debug Toolbar some of our views do a lot of SQL requests. I want to increase the performance of it by reducing the number of SQL requests (e.g. by adding more select_related
, more clever queries, etc.). I would like to be able to measure the improvement as I go along, to encourage me and to be able to say how much fat has been trimmed. I have a large set of django unit tests for this app that touch on lots of parts of the code.
Is there some library/programme/script can run the unittests and then print out how many SQL requests in total were executed? This way I can iterativly improve our app.
This information is only available in debug mode. I'm not aware of any library to do exactly what you are trying to do, however you could probably rig something up pretty easily.
If you are in running in debug mode, then you can view all the queries that have been run with connection.queries
. This is effectively how django debug toolbar works as well.
So alter your unittests to look at the connection.queries dict and that should get you started pretty well.
这篇关于有没有一个图书馆来基准我的Django应用程序的SQL请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!