Python gzip模块基准测试
2016-02-18 16:30
465 查看
解压性能测试
以下是压缩性能测试
test.data 是有三列数字域的文本文件。
注意: 测试机是四核的, 这意味着将gzip作为子进程会比在单核机器上要快一点点。
结论: 同样的,os.popen(gzip) 是最快的方法。引入io.BufferedReader()能加速自带模块的速度。
以下是压缩性能测试
test.data 是有三列数字域的文本文件。
注意: 测试机是四核的, 这意味着将gzip作为子进程会比在单核机器上要快一点点。
# time head -c 8m test.data | gzip > test.data.gz real 0m1.133s user 0m1.085s sys 0m0.023s # time head -c 8m test.data | python2.7 -c 'import gzip, sys; gzip.open("test.data.gz", "w").writelines(sys.stdin)' real 0m8.779s user 0m8.715s sys 0m0.041s # time head -c 8m test.data | python2.7 -c 'import gzip, sys, io; io.BufferedWriter(gzip.open("test.data.gz", "w")).writelines(sys.stdin)' real 0m4.207s user 0m4.156s sys 0m0.042s # time head -c 8m test.data | python2.7 -c 'import sys, os; os.popen("gzip > test.data.gz", "w").writelines(sys.stdin)' real 0m1.237s user 0m1.195s sys 0m0.074s
结论: 同样的,os.popen(gzip) 是最快的方法。引入io.BufferedReader()能加速自带模块的速度。
相关文章推荐
- 在Ubuntu系统下安装使用Python的GUI工具wxPython
- python 基于windows环境的ftp功能
- 用Python进行SQLite数据库操作
- python super关键字
- 以一个投票程序的实例来讲解Python的Django框架使用
- Python入门(转)
- python中文乱码的解决方法
- Python偏函数
- python-整理-logging日志
- python poly1d 实例
- Python-语法
- 【翻译】Leapmotion-python开发官方文档(2)
- Python日志库logging
- 开发中常遇到的Python陷阱和注意点
- Python-库
- PythonGUI-TK、Pyside
- ctypes库
- 使用Python生成随机密码的示例分享
- 《笨办法学Python》 第40课手记
- python使用正則表達式