用cython编译的版本替换选定的django模块,以提高速度。

django_speedboost的Python项目详细描述


Django SpeedBoost

用cython编译的版本替换选定的django模块,以提高速度。

基本原理

代码总是有瓶颈,django也不例外。通过用cython有选择地编辑django的热点, 我们可以让它走得更快。django speedboost是一个插件模块,在安装时用它的 基于cython的版本。

要求

  • Python:2.7
  • django:1.8.8

django speedboost的测试套件在安装后运行django测试套件,以验证它不会执行任何操作 不相容的。

安装

Django SpeedBoost目前仅为Django 1.8.8编译。安装时使用:

pip install django_speedboost

如果缺少头编译错误,请安装发行版的python库开发头,用于 ubuntu上的示例:

sudo apt-get install libpython-dev

工作原理

django speedboost包含一个.pth文件,允许它在python解释器加载点导入自己。 它使用这个来安装一个导入钩子,该钩子检测django子模块的加载以替换它们。

当前更换的模块:

  • django.template.context
  • django.template.context_processors
  • django.template.base
  • django.template.defaulttags

结果

在apache 2后面使用wsgi设置django,ab在加载的管理页面上显示了一致的13%的加载时间减少 内联和字段的数目:

(venv)ddalex@watson ~/Projects/backend(T7569)$ diff --side-by-side without_so.txt with_so.txt
This is ApacheBench, Version 2.3 <$Revision: 1604373 $>             This is ApacheBench, Version 2.3 <$Revision: 1604373 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.ze       Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.ze
Licensed to The Apache Software Foundation, http://www.apache       Licensed to The Apache Software Foundation, http://www.apache

Benchmarking guest (be patient).....done                    Benchmarking guest (be patient).....done


Server Software:        Apache/2.4.7                                Server Software:        Apache/2.4.7
Server Hostname:        guest                                       Server Hostname:        guest
Server Port:            80                                  Server Port:            80

Document Path:          /admin/model/object/57/             Document Path:          /admin/model/object/57/
Document Length:        619067 bytes                                Document Length:        619067 bytes

Concurrency Level:      2                                   Concurrency Level:      2
Time taken for tests:   15.724 seconds                            | Time taken for tests:   13.932 seconds
Complete requests:      20                                  Complete requests:      20
Failed requests:        0                                   Failed requests:        0
Total transferred:      12390600 bytes                              Total transferred:      12390600 bytes
HTML transferred:       12381340 bytes                              HTML transferred:       12381340 bytes
Requests per second:    1.27 [#/sec] (mean)               | Requests per second:    1.44 [#/sec] (mean)
Time per request:       1572.402 [ms](mean)| Time per request:       1393.243 [ms](mean)
Time per request:       786.201 [ms](mean, across all concur |     Time per request:       696.621 [ms](mean, across all concur
Transfer rate:          769.54 [Kbytes/sec] received              | Transfer rate:          868.49 [Kbytes/sec] received

Connection Times (ms)                                               Connection Times (ms)
              min  mean[+/-sd] median   max                               min  mean[+/-sd] median   max
Connect:        000.1      01| Connect:        000.0      00
Processing:   6241570723.5   20082313| Processing:   5851391578.5   17641991
Waiting:      6211566722.6   19992311| Waiting:      5721381578.2   17411988
Total:        6241570723.5   20082313| Total:        5851391578.5   17641991

Percentage of the requests served within a certain time(ms)        Percentage of the requests served within a certain time(ms)50%   2008|50%   176466%   2106|66%   184575%   2237|75%   191780%   2263|80%   193690%   2288|90%   198195%   2313|95%   199198%   2313|98%   199199%   2313|99%   1991100%   2313(longest request)|100%   1991(longest request)

历史记录

未来

1.8.8.0(2016-01-06)

  • 第一个正确的django 1.8.8版本。替换django.template中的4个模块。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
内存Java正在运行。jar heapdump错误   java如何在安卓画布中弯曲文本区域?   java如何在Gdx 安卓游戏编程中获得矩形的真实触碰位置?   找不到java Spring MVC控制器   在Java中使用双重检查锁定单例扩展类   java在高效的时间和内存中动态执行insert(索引、数据)、delete(索引)、getAt(索引)操作。   java 安卓 Toast和视图帮助   java协议缓冲区:从文件中读取所有序列化消息   java如何在Jackson中为参数化接口类型执行通用自定义反序列化程序   与简单的空检查相比,使用(平面)映射的java优势是什么?   异步方法seam中的java Get contextparam   jar使用相同的java运行时运行另一个java程序   java访问Spring批处理中的作业参数   java给定字符串为空或null   在h2数据库1.4中找不到java类“org.h2.fulltext.FullTextLucene”。*不适用于Lucene Core 4*   java Spring Boot在使用@enableSync时不响应任何请求   java错误:在bash上找不到或加载主类pj2   “返回对象”和“返回(对象)”之间的Java差异   java Android开发:如何使用onKeyUp?