2007-02-17

cProfile output for Math Class Melee

Following the style of Peter Lin, here's a rather dull post ;-)

# find_solution: +O+O+O+O+O+A+A+A+A+A+A+A+A+A+A+A+A+B+B+B+j+B+B+j+B+B+B+B+B+B+j+B+B+B+B+B+B+j+j+j+j+j+j+j+j+j+j+j+j+j+j+j+j+P
# Activation 59/100, find_solution: {'g4': , 'g3': , 'g2': , 'g1': , 'g': }
260778 function calls (255201 primitive calls) in 1.083 CPU seconds

Ordered by: standard name

ncalls tottime percall cumtime percall filename:lineno(function)
65 0.000 0.000 0.000 0.000 __init__.py:222(_watch_callback)
128 0.000 0.000 0.000 0.000 __init__.py:227(_index_generator)
64 0.001 0.000 0.001 0.000 __init__.py:308(___new___)
69 0.000 0.000 0.000 0.000 __init__.py:357(__repr__)
64 0.000 0.000 1.081 0.017 __init__.py:57(assert_fact)
3078 0.059 0.000 0.102 0.000 copy.py:299(_reconstruct)
3078 0.039 0.000 0.212 0.000 copy.py:65(copy)
3078 0.007 0.000 0.007 0.000 copy_reg.py:91(__newobj__)
1 0.000 0.000 0.000 0.000 copy_reg.py:94(_slotnames)
64 0.000 0.000 0.000 0.000 math_class_melee.py:23(__init__)
1 0.001 0.001 1.083 1.083 math_class_melee.py:44(generate_possibilities)
320 0.005 0.000 1.078 0.003 rete.py:131(activate)
411/320 0.003 0.000 1.070 0.003 rete.py:195(activate)
40 0.001 0.000 1.036 0.026 rete.py:289(activate)
12 0.000 0.000 0.582 0.048 rete.py:330(right_activate)
1104/124 0.028 0.000 0.969 0.008 rete.py:361(left_activate)
188 0.006 0.000 0.050 0.000 rete.py:369(right_activate)
13754 0.116 0.000 0.286 0.000 rete.py:377(join)
925/251 0.004 0.000 0.935 0.004 rete.py:401(propagate)
882/178 0.182 0.000 0.729 0.004 rete.py:475(left_activate)
754/402 0.176 0.000 0.765 0.002 rete.py:498(right_activate)
1189/268 0.012 0.000 0.948 0.004 rete.py:522(propagate)
2126/271 0.060 0.000 0.978 0.004 rete.py:548(activate)
1 0.000 0.000 0.000 0.000 rete.py:607(activate)
1798 0.011 0.000 0.011 0.000 rete.py:624(__init__)
64 0.001 0.000 1.079 0.017 rete.py:77(assert_fact)
64 0.001 0.000 1.080 0.017 workingmemory.py:112(assert_fact)
64 0.000 0.000 0.000 0.000 {built-in method __new__ of type object at 0x1E1E6DD0}
1889 0.007 0.000 0.013 0.000 {eval}
6156 0.017 0.000 0.017 0.000 {getattr}
3079 0.009 0.000 0.009 0.000 {hasattr}
3078 0.003 0.000 0.003 0.000 {id}
17485 0.026 0.000 0.026 0.000 {isinstance}
3078 0.004 0.000 0.004 0.000 {len}
3078 0.046 0.000 0.046 0.000 {method '__reduce_ex__' of 'object' objects}
1993 0.002 0.000 0.002 0.000 {method 'append' of 'list' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
6156 0.007 0.000 0.007 0.000 {method 'get' of 'dict' objects}
1 0.000 0.000 0.000 0.000 {method 'get' of 'dictproxy' objects}
172027 0.223 0.000 0.223 0.000 {method 'keys' of 'dict' objects}
7223 0.016 0.000 0.016 0.000 {method 'update' of 'dict' objects}
1 0.000 0.000 0.000 0.000 {method 'write' of 'file' objects}
1 0.000 0.000 0.000 0.000 {range}
256 0.000 0.000 0.000 0.000 {setattr}

Fred 1 orange
Joe 2 blue
Bob 4 plaid
Tom 3 red
The ouput is from asserting the objects representing the 64 combinations of Golfer's name, position and pants color. It might not make much sense to you but I can assure you that it's quite helpful to me. The blue output is from pyRete, the black is from the cProfile module.

I've highlighted a few of the most interesting lines with red. One of the things that can be deduced from this is that pyRete relies heavily on Python's built-in dictionary object and the copy module. It manages to call copy.copy 3078 times and dict.keys() a staggering 172027 times!!! I *think* there may be room for improvment.

1 kommentar:

woolfel sa...

LOL, I got a good laugh at that.