avalo-fs
avalo-fs是一个Pytho的编译构造工具,能够将你的代码Cytho
使用avalo-fs的好处代码Cytho化:Widows下把代码编译为pyd,Liux下把代码编译为.so,有效的保护源代码获得性能提升:能够在不做任何代码级别优化的情况下,对Pytho代码进行性能提升安装pipistallavalo-fs编译项目avalo-fs-buildbuild_ext编译完毕后,对应的文件会在./build/lib*底下
使用编译后的文件avalo-fs-release执行此命令会把build目录下的编译文件替换到根目录下,仅在编译发布环境使用
##配置文件当有定制参数的时候,可以在项目根目录下新建配置文件avalo-fs.jso
{"remove_models":[],"remove_files":[]}配置名称配置描述remove_models不参与编译的模块remove_files不参与编译的文件性能对比importtimedefru():time_start=time.time()importsysdefmake_tree(depth):ifotdepth:returNoe,Noedepth-=1returmake_tree(depth),make_tree(depth)defcheck_tree(ode):(left,right)=odeifotleft:retur1retur1+check_tree(left)+check_tree(right)mi_depth=4max_depth=max(mi_depth+2,17)stretch_depth=max_depth+1prit("stretchtreeofdepth%d\tcheck:"%stretch_depth,check_tree(make_tree(stretch_depth)))log_lived_tree=make_tree(max_depth)iteratios=2**max_depthfordepthirage(mi_depth,stretch_depth,2):check=0foriirage(1,iteratios+1):check+=check_tree(make_tree(depth))prit("%d\ttreesofdepth%d\tcheck:"%(iteratios,depth),check)iteratios//=4prit("loglivedtreeofdepth%d\tcheck:"%max_depth,check_tree(log_lived_tree))time_ed=time.time()prit('timecost',time_ed-time_start,'s')纯Pythostretchtreeofdepth18check:524287131072treesofdepth4check:406323232768treesofdepth6check:41615368192treesofdepth8check:41861122048treesofdepth10check:4192256512treesofdepth12check:4193792128treesofdepth14check:419417632treesofdepth16check:4194272loglivedtreeofdepth17check:262143timecost11.279994249343872sCytho化stretchtreeofdepth18check:524287131072treesofdepth4check:406323232768treesofdepth6check:41615368192treesofdepth8check:41861122048treesofdepth10check:4192256512treesofdepth12check:4193792128treesofdepth14check:419417632treesofdepth16check:4194272loglivedtreeofdepth17check:262143timecost1.9600331783294678s简单编译之后,性能直接就提升近6倍
评论