Created
January 8, 2014 13:10
-
-
Save iurisilvio/8316537 to your computer and use it in GitHub Desktop.
A simple openpyxl profiler to optimized reader
This file contains hidden or 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
--- a/openpyxl/reader/iter_worksheet.py Thu Jan 02 23:46:28 2014 +0100 | |
+++ b/openpyxl/reader/iter_worksheet.py Tue Jan 07 22:26:45 2014 +0100 | |
@@ -254,6 +254,7 @@ | |
data_type = Cell.TYPE_FORMULA | |
value = "=" + formula | |
yield RawCell(row, column_str, coord, value, data_type, style_id, None) | |
+ element.clear() |
This file contains hidden or 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
import openpyxl | |
from memory_profiler import memory_usage | |
print openpyxl.__version__ | |
f = "openpyxl/benchmarks/files/large.xlsx" | |
r = openpyxl.load_workbook(f, use_iterators=True) | |
w = r.worksheets[1] | |
for n, line in enumerate(w.iter_rows()): | |
if n % 50 == 0: | |
print n, memory_usage(-1, interval=1) |
This file contains hidden or 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
F:\projects\openpyxl>python setup.py develop | |
running develop | |
running egg_info | |
writing openpyxl.egg-info\PKG-INFO | |
writing top-level names to openpyxl.egg-info\top_level.txt | |
writing dependency_links to openpyxl.egg-info\dependency_links.txt | |
reading manifest file 'openpyxl.egg-info\SOURCES.txt' | |
reading manifest template 'MANIFEST.in' | |
no previously-included directories found matching 'openpyxl\sample' | |
writing manifest file 'openpyxl.egg-info\SOURCES.txt' | |
running build_ext | |
Creating c:\python27\lib\site-packages\openpyxl.egg-link (link to .) | |
Adding openpyxl 1.8.0 to easy-install.pth file | |
Installed f:\projects\openpyxl | |
Processing dependencies for openpyxl==1.8.0 | |
Finished processing dependencies for openpyxl==1.8.0 | |
F:\projects\openpyxl>python bench.py | |
1.8.0 | |
0 [28.640625] | |
50 [198.54296875] | |
100 [366.6328125] | |
150 [531.54296875] | |
200 [700.52734375] | |
250 [868.36328125] | |
300 [1032.25] | |
350 [1195.89453125] | |
400 [1359.53515625] | |
450 [1524.5390625] | |
500 [1689.78515625] | |
550 [1855.75390625] | |
600 [2023.0625] | |
650 [2188.19921875] | |
700 [2354.12890625] | |
750 [2521.015625] | |
800 [2687.07421875] | |
850 [2852.94140625] | |
900 [3020.12890625] | |
950 [3184.36328125] | |
F:\projects\openpyxl>hg patch 1.patch --no-commit | |
applying 1.patch | |
F:\projects\openpyxl>hg patch 1.patch | |
abort: outstanding uncommitted changes | |
F:\projects\openpyxl>python bench.py | |
1.8.0 | |
0 [26.56640625] | |
50 [54.6953125] | |
100 [80.68359375] | |
150 [106.234375] | |
200 [131.25390625] | |
250 [156.3203125] | |
300 [181.2578125] | |
350 [206.47265625] | |
400 [231.68359375] | |
450 [256.8828125] | |
500 [282.515625] | |
550 [308.0390625] | |
600 [333.33984375] | |
650 [358.58203125] | |
700 [383.47265625] | |
750 [408.328125] | |
800 [433.875] | |
850 [459.72265625] | |
900 [484.60546875] | |
950 [509.8359375] | |
F:\projects\openpyxl>hg update --clean | |
1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
F:\projects\openpyxl>hg checkout 1.6.2 | |
0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
F:\projects\openpyxl>python bench.py | |
1.6.2 | |
0 [20.4921875] | |
50 [23.3671875] | |
100 [23.3671875] | |
150 [23.3671875] | |
200 [23.3671875] | |
250 [23.3671875] | |
300 [23.58203125] | |
350 [23.58203125] | |
400 [23.58203125] | |
450 [23.58203125] | |
500 [23.58203125] | |
550 [23.58203125] | |
600 [23.59375] | |
650 [23.59375] | |
700 [23.59375] | |
750 [23.59375] | |
800 [23.59375] | |
850 [23.59375] | |
900 [23.57421875] | |
950 [23.57421875] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment