Share 
Follow 
AboutDownloadsForumsSource CodeIssues
Date:
2010-08-07 06:50
Priority:
3
State:
Open
Submitted by:
John Chodera (jchodera)
Assigned to:
Christopher Bruns (cmbruns)
Summary:
Replace simtk/unit/mymatrix.py functionality with numpy, if present?

Detailed description
I finally did some profiling of Randy's elegant Python Amber prmtop reader using cProfile, and it seems that much of the time is being consumed by operations in simtk/unit/mymatrix.py. I recognize that it's great to have a pure Python version in case someone doesn't want to install numpy (though I insist this is *very* standard in any scientific computing Python context), but sweet jesus! it seems to be killing performance, assuming I'm reading these numbers right (see below). Reading a 122-residue protein takes over two minutes!

We're discussing C++ prmtop file readers in a week or two, which might solve the problem, but it would still be lovely (when time permits!) to take a look at the performance issues in simtk.unit. It's a wonderful thing, but it would be great if there was a way to make it fast as well as useful.

John

-- cProfile output follows --

Fri Aug 6 23:18:56 2010 fooprof

109125729 function calls (108972503 primitive calls) in 129.894 CPU seconds

Ordered by: internal time
List reduced from 140 to 30 due to restriction <30>

ncalls tottime percall cumtime percall filename:lineno(function)
66411 19.970 0.000 59.614 0.001 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/mymatrix.py:179(__mul__)
10293705 16.509 0.000 34.506 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/mymatrix.py:166(__getitem__)
22327904 10.311 0.000 10.311 0.000 {isinstance}
3286798 10.102 0.000 12.322 0.000 {sorted}
13459805 9.161 0.000 11.056 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/basedimension.py:56(__hash__)
10426527 8.830 0.000 13.318 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/mymatrix.py:50(__init__)
1953992 7.338 0.000 17.497 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:88(iter_base_dimensions)
306990 6.614 0.000 12.392 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:23(__init__)
161706 3.642 0.000 24.384 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit_operators.py:49(_unit_class_mul)
10227294 3.600 0.000 3.600 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/mymatrix.py:62(__getitem__)
66411 2.719 0.000 85.129 0.001 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:551(express_unit)
214536 2.618 0.000 16.650 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:252(is_compatible)
1847810 2.036 0.000 2.591 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/basedimension.py:46(__cmp__)
627447 1.920 0.000 4.336 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:114(iter_top_base_units)
13459805 1.896 0.000 1.896 0.000 {hash}
480692 1.568 0.000 4.034 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:101(iter_all_base_units)
3254139 1.534 0.000 1.534 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/mymatrix.py:78(__setitem__)
76613 1.376 0.000 12.359 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:281(conversion_factor_to)
251533 1.372 0.000 1.630 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/baseunit.py:59(get_dimension_tuple)
734840 1.240 0.000 3.271 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:443(__iter__)
736072 1.188 0.000 5.822 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:127(iter_base_or_scaled_units)
26624 0.891 0.000 6.167 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/quantity.py:264(reduce_unit)
28394 0.813 0.000 111.367 0.004 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/chem/openmm/openmm.py:519(stripUnits)
806536 0.727 0.000 0.727 0.000 {range}
3286798 0.718 0.000 0.718 0.000 {method 'iterkeys' of 'dict' objects}
2204968 0.698 0.000 0.698 0.000 {cmp}
208640 0.670 0.000 1.457 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/quantity.py:88(__init__)
662047 0.632 0.000 0.996 0.000 {method 'sort' of 'list' objects}
159589 0.590 0.000 3.611 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:272(is_dimensionless)
103524 0.570 0.000 3.302 0.000 /Users/jchodera/local/python/lib/python2.6/site-packages/simtk/unit/unit.py:459(get_dimension_tuple)

Add A Comment: Notepad

No Comments Have Been Posted

No Changes Have Been Made to This Item

Feedback