Created
January 31, 2014 08:48
-
-
Save PyYoshi/8728593 to your computer and use it in GitHub Desktop.
bench chardet. require: https://raw.github.com/PyYoshi/cChardet/master/test/testdata/wikipediaJa_One_Thousand_and_One_Nights_SJIS.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
import chardet | |
import time | |
def main(): | |
do_times = 10 | |
path = r"wikipediaJa_One_Thousand_and_One_Nights_SJIS.txt" | |
with open(path, 'rb') as f: | |
msg = f.read() | |
result_chardet = 0 | |
for i in range(do_times): | |
start_chardet = time.time() | |
chardet.detect(msg) | |
result_chardet += (time.time() - start_chardet) | |
print('chardet:',1/(result_chardet/do_times), 'call(s)/s') | |
if '__main__' in __name__: | |
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python --version | |
Python 2.7.6 | |
$ python ./bench.py | |
('chardet:', 0.13635000826167848, 'call(s)/s') | |
$ python --version | |
Python 2.7.3 (87aa9de10f9c, Nov 24 2013, 18:48:13) | |
[PyPy 2.2.1 with GCC 4.6.3] | |
$ python ./bench.py | |
('chardet:', 1.0764693665798812, 'call(s)/s') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment