python性能调谐器

ppt的Python项目详细描述


PPT-Python性能调谐器

ppt是调整Python程序性能的工具

安装

pip install ppt

示例

计时

importpptimporttimeif__name__=='__main__':for_inrange(10):ppt.time('big')time.sleep(0.5)# Big computationppt.time('medium')time.sleep(0.3)# Medium computationppt.time('fast')time.sleep(0.01)# Fast computation# Stop current timingppt.stop()# Print current timingsppt.summary()# Detailed statistics from pstatsppt.stats()

输出

big: 40 function calls in 5.006 seconds
medium: 40 function calls in 3.003 seconds
fast: 40 function calls in 0.101 seconds
********** big **********
         40 function calls in 5.006 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
       10    5.005    0.501    5.005    0.501 {built-in method time.sleep}
       10    0.000    0.000    0.000    0.000 /home/seba-1511/Dropbox/Dev/perf/ppt/profiler.py:42(time)
       10    0.000    0.000    0.000    0.000 /home/seba-1511/Dropbox/Dev/perf/ppt/profiler.py:17(stop)
       10    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}


********** medium **********
         40 function calls in 3.003 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
       10    3.003    0.300    3.003    0.300 {built-in method time.sleep}
       10    0.000    0.000    0.000    0.000 /home/seba-1511/Dropbox/Dev/perf/ppt/profiler.py:42(time)
       10    0.000    0.000    0.000    0.000 /home/seba-1511/Dropbox/Dev/perf/ppt/profiler.py:17(stop)
       10    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}


********** fast **********
         40 function calls in 0.101 seconds

   Ordered by: cumulative time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
       10    0.101    0.010    0.101    0.010 {built-in method time.sleep}
        9    0.000    0.000    0.000    0.000 /home/seba-1511/Dropbox/Dev/perf/ppt/profiler.py:42(time)
       10    0.000    0.000    0.000    0.000 /home/seba-1511/Dropbox/Dev/perf/ppt/profiler.py:17(stop)
        1    0.000    0.000    0.000    0.000 /home/seba-1511/Dropbox/Dev/perf/ppt/profiler.py:53(stop)
       10    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

绘制

下面启动visdom服务器并绘制4行随机样本。

importpptimportrandom,timeif__name__=='__main__':ppt.plot(1)ppt.plot(1)ppt.plot(1)ppt.plot(1)foriinrange(10):forsessionin['a','b','c','d']:time.sleep(0.2)ppt.plot(random.random(),session)ppt.close()

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

推荐PyPI第三方库


热门话题
Java类之间并发性不一致的HashMap   插件如何在JavaSwing中使用UIManager和Classloader从外部jar安装外观?   java JasperReports:找不到子报表   在项目中找不到java生成的Javadoc文件   java BigDecimal。multiply()和divide()方法返回十六进制数。为什么?   java统计出现次数并从字符串中删除重复项   调用运算符时发生java NullPointerException   Spring和Hibernate之间的java配置错误   JavaZK将用户重定向回上一页   Javasocket为传出连接指定特定的网络接口   如果拖动到某个区域外,java Make按钮操作将被取消   如何在Eclipse for selenium 3.141.59中添加Java文档链接   java从匹配条件的数组中获取所有索引   docker未连接到RemoteWebDriver的java Gitlab ci selenium测试   java重写run方法   utf 8如何使用java解码UTF8编码的字符串?   java如何从eclipse调试部署在tomcat上的web应用程序?   将字母字符与前面没有百分号的Java正则表达式匹配