Skip to content

Instantly share code, notes, and snippets.

@kurtbrose
Created June 28, 2012 00:14
Show Gist options
  • Save kurtbrose/3007786 to your computer and use it in GitHub Desktop.
Save kurtbrose/3007786 to your computer and use it in GitHub Desktop.
performance comparison of class versus closure based parsing
BINARY PARSING TEST.....
without instrumentation:
1.2692489624 seconds
Wed Jun 27 17:01:13 2012 profile.tmp
1431592 function calls (1343306 primitive calls) in 2.614 CPU seconds
Ordered by: internal time
List reduced from 99 to 30 due to restriction <30>
ncalls tottime percall cumtime percall filename:lineno(function)
22977/44 0.222 0.000 1.864 0.042 ../asf/serdes.py:202(parse_field)
22977/44 0.181 0.000 0.759 0.017 ../asf/serdes_bin.py:265(parse_field)
10961 0.148 0.000 0.228 0.000 ../asf/asf_context.py:213(get_or_make_vo_type)
47456/45954 0.123 0.000 0.278 0.000 ../asf/fields.py:76(validate)
142917 0.117 0.000 0.191 0.000 {isinstance}
22977 0.110 0.000 0.351 0.000 ../asf/fields.py:264(__setattr__)
3833 0.109 0.000 0.596 0.000 ../asf/fields.py:227(_setup)
3833/8 0.098 0.000 1.866 0.233 ../asf/serdes.py:228(parse_vo)
46051 0.097 0.000 0.123 0.000 ../asf/serdes_bin.py:375(parse_int)
22977 0.095 0.000 0.095 0.000 ../asf/fields.py:46(__init__)
88723 0.089 0.000 0.116 0.000 {getattr}
26950/8 0.065 0.000 1.866 0.233 ../asf/serdes.py:194(g)
3965/77 0.063 0.000 0.756 0.010 ../asf/serdes_bin.py:357(parse_vo)
35641 0.054 0.000 0.073 0.000 /x/opt/pp/lib/python2.6/abc.py:120(__instancecheck__)
24369 0.051 0.000 0.109 0.000 ../asf/serdes_bin.py:414(consume)
37233 0.048 0.000 0.072 0.000 {issubclass}
101346 0.043 0.000 0.043 0.000 {len}
101151 0.043 0.000 0.043 0.000 {method 'has_key' of 'dict' objects}
3833 0.041 0.000 0.057 0.000 ../asf/fields.py:187(resolvecallargs)
22977 0.038 0.000 0.389 0.000 {setattr}
24369 0.037 0.000 0.048 0.000 ../asf/serdes_bin.py:419(expect)
6523 0.037 0.000 0.063 0.000 /x/opt/pp/lib/python2.6/decimal.py:512(__new__)
38670 0.034 0.000 0.034 0.000 {built-in method __new__ of type object at 0x816f580}
7128 0.034 0.000 0.063 0.000 ../asf/fields.py:314(__init__)
14182 0.029 0.000 0.170 0.000 ../asf/serdes_bin.py:330(parse_primitive)
53082 0.027 0.000 0.027 0.000 ../asf/fields.py:104(__get__)
55361 0.027 0.000 0.027 0.000 {method 'append' of 'list' objects}
22977 0.024 0.000 0.024 0.000 /x/opt/pp/lib/python2.6/abc.py:137(__subclasscheck__)
6332/69 0.024 0.000 0.751 0.011 ../asf/serdes_bin.py:316(parse_list)
4151 0.023 0.000 0.067 0.000 /x/opt/pp/lib/python2.6/decimal.py:1559(_fix)
Wed Jun 27 17:02:51 2012 profile.tmp
1856330 function calls (1768044 primitive calls) in 3.027 CPU seconds
Ordered by: internal time
List reduced from 104 to 30 due to restriction <30>
ncalls tottime percall cumtime percall filename:lineno(function)
22977/44 0.227 0.000 1.965 0.045 ../asf/serdes.py:201(parse_field)
22977/44 0.181 0.000 1.073 0.024 ../asf/serdes_bin.py:253(parse_field)
10961 0.176 0.000 0.256 0.000 ../asf/asf_context.py:213(get_or_make_vo_type)
46051 0.138 0.000 0.255 0.000 ../asf/serdes_bin.py:361(parse_int)
47456/45954 0.127 0.000 0.293 0.000 ../asf/fields.py:76(validate)
245387 0.126 0.000 0.126 0.000 ../asf/serdes_bin.py:214(cursor)
144475 0.122 0.000 0.196 0.000 {isinstance}
22977 0.112 0.000 0.362 0.000 ../asf/fields.py:264(__setattr__)
3833 0.111 0.000 0.612 0.000 ../asf/fields.py:227(_setup)
118623 0.102 0.000 0.161 0.000 {method 'send' of 'generator' objects}
3833/8 0.098 0.000 1.967 0.246 ../asf/serdes.py:227(parse_vo)
26950/8 0.097 0.000 1.967 0.246 ../asf/serdes.py:194(g)
88723 0.091 0.000 0.118 0.000 {getattr}
22977 0.081 0.000 0.081 0.000 ../asf/fields.py:46(__init__)
3965/77 0.079 0.000 1.070 0.014 ../asf/serdes_bin.py:343(parse_vo)
24369 0.056 0.000 0.172 0.000 ../asf/serdes_bin.py:400(consume)
35641 0.055 0.000 0.074 0.000 /x/opt/pp/lib/python2.6/abc.py:120(__instancecheck__)
37233 0.050 0.000 0.074 0.000 {issubclass}
24369 0.049 0.000 0.073 0.000 ../asf/serdes_bin.py:405(expect)
103438 0.046 0.000 0.046 0.000 {len}
102124 0.044 0.000 0.044 0.000 {method 'has_key' of 'dict' objects}
3833 0.041 0.000 0.057 0.000 ../asf/fields.py:187(resolvecallargs)
22977 0.039 0.000 0.401 0.000 {setattr}
6523 0.037 0.000 0.061 0.000 /x/opt/pp/lib/python2.6/decimal.py:512(__new__)
7128 0.036 0.000 0.066 0.000 ../asf/fields.py:314(__init__)
80710 0.034 0.000 0.034 0.000 {id}
38670 0.032 0.000 0.032 0.000 {built-in method __new__ of type object at 0x816f580}
14182 0.029 0.000 0.229 0.000 ../asf/serdes_bin.py:317(parse_primitive)
53082 0.027 0.000 0.027 0.000 ../asf/fields.py:104(__get__)
55361 0.027 0.000 0.027 0.000 {method 'append' of 'list' objects}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment