-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance improvement 12: Optimize NocaseDict._real_key()
Details: - This change optimizes the implementaiton of NocaseDict._real_key() by replacing a check using isinstance() with a check for None, turning around the order of checks. Also, replaced if/elif/else with a sequence of if's. This eliminates a call to isinstance(). Improvement: Output files before: perf/tupleparse/perf_11-nocasedict_* Output files after: perf/tupleparse/perf_12-nocasedict_* Signed-off-by: Andreas Maier <maiera@de.ibm.com>
- Loading branch information
1 parent
80c816d
commit 19450c4
Showing
4 changed files
with
161 additions
and
6 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
perf/tupleparse/perf_12-nocasedict_cprofile_20190302-165534_10000_500.out
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
9800503 function calls (9560498 primitive calls) in 6.034 seconds | ||
|
||
Ordered by: internal time, call count | ||
List reduced from 158 to 25 due to restriction <25> | ||
|
||
ncalls tottime percall cumtime percall filename:lineno(function) | ||
80000 0.901 0.000 1.196 0.000 collections.py:50(__init__) | ||
140005 0.426 0.000 0.683 0.000 tupleparse.py:165(check_node) | ||
140005 0.365 0.000 0.444 0.000 tupletree.py:96(startElement) | ||
92 0.275 0.003 1.272 0.014 {built-in method Parse} | ||
1740019 0.265 0.000 0.265 0.000 {isinstance} | ||
250005 0.184 0.000 0.263 0.000 tupleparse.py:117(kids) | ||
80000 0.175 0.000 0.189 0.000 _abcoll.py:548(update) | ||
120004/1 0.174 0.000 4.752 4.752 tupleparse.py:2057(parse_any) | ||
40000 0.170 0.000 1.363 0.000 cim_obj.py:4324(__init__) | ||
100000/20000 0.160 0.000 2.843 0.000 tupleparse.py:323(list_of_matching) | ||
30000 0.155 0.000 1.944 0.000 tupleparse.py:1318(parse_property) | ||
80000 0.139 0.000 1.335 0.000 _nocasedict.py:90(__init__) | ||
300007 0.120 0.000 0.174 0.000 tupletree.py:115(characters) | ||
140005 0.109 0.000 0.572 0.000 expatreader.py:335(start_element) | ||
260000 0.078 0.000 0.132 0.000 _utils.py:41(_ensure_unicode) | ||
40000 0.073 0.000 0.673 0.000 tupleparse.py:2147(unpack_value) | ||
300007 0.070 0.000 0.244 0.000 pyexpat.c:441(CharacterData) | ||
570010 0.069 0.000 0.069 0.000 {method 'append' of 'list' objects} | ||
10000 0.068 0.000 3.661 0.000 tupleparse.py:1128(parse_instance) | ||
40000 0.066 0.000 0.229 0.000 cim_obj.py:2635(__setitem__) | ||
20000 0.065 0.000 0.462 0.000 cim_obj.py:1252(keybindings) | ||
80000 0.062 0.000 0.099 0.000 abc.py:148(__subclasscheck__) | ||
10000 0.058 0.000 0.656 0.000 tupleparse.py:1375(parse_property_array) | ||
550019 0.058 0.000 0.058 0.000 tupleparse.py:103(name) | ||
60000 0.057 0.000 0.057 0.000 collections.py:71(__setitem__) | ||
|
||
|
||
Results: profile=cprofile, response_counts=[10000], | ||
response-sizes=[500], runid=12-nocasedict 20190302-165534 | ||
+------------+------------+------------+---------+--------------+-------------+ | ||
| Exp inst | Act inst | Response | XML | Parse time | Instances | | ||
| size | size | Count | size | sec. | per sec | | ||
+============+============+============+=========+==============+=============+ | ||
| 500 | 589 | 10000 | 5896919 | 6.12 | 1634 | | ||
+------------+------------+------------+---------+--------------+-------------+ |
Binary file added
BIN
+52.8 KB
perf/tupleparse/perf_12-nocasedict_cprofile_20190302-165534_10000_500.profile
Binary file not shown.
113 changes: 113 additions & 0 deletions
113
perf/tupleparse/perf_12-nocasedict_pyinst_20190302-165607_10000_500.out
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
|
||
_ ._ __/__ _ _ _ _ _/_ Recorded: 16:56:33 Samples: 2641 | ||
/_//_/// /_\ / //_// / //_'/ // Duration: 5.284 | ||
/ _/ v3.0.1 | ||
|
||
Program: tests/manualtest/run_response_performance.py -i -c 1000 10000 -s 500 -n 25 -l -p pyinst -r 12-nocasedict | ||
|
||
[31m5.284[0m [48;5;24m[38;5;15mexecute_test_code[0m [2mrun_response_performance.py:193[0m | ||
├─ [31m4.136[0m [48;5;24m[38;5;15mparse_cim[0m [2mpywbem/tupleparse.py:384[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mone_child[0m [2mpywbem/tupleparse.py:250[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mparse_message[0m [2mpywbem/tupleparse.py:1631[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mone_child[0m [2mpywbem/tupleparse.py:250[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mparse_simplersp[0m [2mpywbem/tupleparse.py:1892[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mone_child[0m [2mpywbem/tupleparse.py:250[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mparse_imethodresponse[0m [2mpywbem/tupleparse.py:1947[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mlist_of_various[0m [2mpywbem/tupleparse.py:302[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ └─ [31m4.136[0m [48;5;24m[38;5;15mparse_ireturnvalue[0m [2mpywbem/tupleparse.py:2014[0m | ||
│ └─ [31m4.128[0m [48;5;24m[38;5;15mlist_of_same[0m [2mpywbem/tupleparse.py:339[0m | ||
│ └─ [31m4.107[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ └─ [31m4.073[0m [48;5;24m[38;5;15mparse_value_namedinstance[0m [2mpywbem/tupleparse.py:538[0m | ||
│ ├─ [31m3.310[0m [48;5;24m[38;5;15mparse_instance[0m [2mpywbem/tupleparse.py:1128[0m | ||
│ │ ├─ [33m2.842[0m [48;5;24m[38;5;15mlist_of_matching[0m [2mpywbem/tupleparse.py:323[0m | ||
│ │ │ └─ [33m2.743[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ │ │ ├─ [33m2.123[0m [48;5;24m[38;5;15mparse_property[0m [2mpywbem/tupleparse.py:1318[0m | ||
│ │ │ │ ├─ [33m1.442[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/cim_obj.py:4324[0m | ||
│ │ │ │ │ ├─ [33m1.153[0m [48;5;24m[38;5;15mqualifiers[0m [2mpywbem/cim_obj.py:4789[0m | ||
│ │ │ │ │ │ └─ [33m1.132[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/_nocasedict.py:90[0m | ||
│ │ │ │ │ │ ├─ [32m0.635[0m __init__[0m [2mcollections.py:50[0m | ||
│ │ │ │ │ │ │ [8 frames hidden] [2mcollections, _abcoll, abc, _weakrefset[0m | ||
│ │ │ │ │ │ └─ [32m0.497[0m [self][0m [2m[0m | ||
│ │ │ │ │ └─ [92m[2m0.068[0m [self][0m [2m[0m | ||
│ │ │ │ ├─ [32m0.361[0m [48;5;24m[38;5;15munpack_value[0m [2mpywbem/tupleparse.py:2147[0m | ||
│ │ │ │ │ ├─ [92m[2m0.198[0m [48;5;24m[38;5;15mlist_of_matching[0m [2mpywbem/tupleparse.py:323[0m | ||
│ │ │ │ │ │ └─ [92m[2m0.165[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ │ │ │ │ │ └─ [92m[2m0.115[0m [48;5;24m[38;5;15mparse_value[0m [2mpywbem/tupleparse.py:450[0m | ||
│ │ │ │ │ │ └─ [92m[2m0.063[0m [48;5;24m[38;5;15mcheck_node[0m [2mpywbem/tupleparse.py:165[0m | ||
│ │ │ │ │ └─ [92m[2m0.126[0m [48;5;24m[38;5;15munpack_single_value[0m [2mpywbem/tupleparse.py:2178[0m | ||
│ │ │ │ │ └─ [92m[2m0.073[0m [48;5;24m[38;5;15munpack_numeric[0m [2mpywbem/tupleparse.py:2291[0m | ||
│ │ │ │ ├─ [92m[2m0.133[0m [48;5;24m[38;5;15mcheck_node[0m [2mpywbem/tupleparse.py:165[0m | ||
│ │ │ │ │ └─ [92m[2m0.107[0m [self][0m [2m[0m | ||
│ │ │ │ └─ [92m[2m0.109[0m [self][0m [2m[0m | ||
│ │ │ ├─ [32m0.541[0m [48;5;24m[38;5;15mparse_property_array[0m [2mpywbem/tupleparse.py:1375[0m | ||
│ │ │ │ ├─ [92m[2m0.211[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/cim_obj.py:4324[0m | ||
│ │ │ │ │ └─ [92m[2m0.107[0m [48;5;24m[38;5;15mqualifiers[0m [2mpywbem/cim_obj.py:4789[0m | ||
│ │ │ │ │ └─ [92m[2m0.102[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/_nocasedict.py:90[0m | ||
│ │ │ │ │ └─ [92m[2m0.077[0m __init__[0m [2mcollections.py:50[0m | ||
│ │ │ │ │ [8 frames hidden] [2mcollections, _abcoll, abc, _weakrefset[0m | ||
│ │ │ │ ├─ [92m[2m0.202[0m [48;5;24m[38;5;15munpack_value[0m [2mpywbem/tupleparse.py:2147[0m | ||
│ │ │ │ │ └─ [92m[2m0.170[0m [48;5;24m[38;5;15mlist_of_matching[0m [2mpywbem/tupleparse.py:323[0m | ||
│ │ │ │ │ └─ [92m[2m0.151[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ │ │ │ │ └─ [92m[2m0.143[0m [48;5;24m[38;5;15mparse_value_array[0m [2mpywbem/tupleparse.py:469[0m | ||
│ │ │ │ │ └─ [92m[2m0.105[0m [48;5;24m[38;5;15mlist_of_various[0m [2mpywbem/tupleparse.py:302[0m | ||
│ │ │ │ │ └─ [92m[2m0.071[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ │ │ │ └─ [92m[2m0.061[0m [self][0m [2m[0m | ||
│ │ │ └─ [92m[2m0.070[0m [self][0m [2m[0m | ||
│ │ ├─ [92m[2m0.183[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/cim_obj.py:2253[0m | ||
│ │ │ ├─ [92m[2m0.083[0m [48;5;24m[38;5;15mqualifiers[0m [2mpywbem/cim_obj.py:2460[0m | ||
│ │ │ │ └─ [92m[2m0.076[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/_nocasedict.py:90[0m | ||
│ │ │ │ └─ [92m[2m0.064[0m __init__[0m [2mcollections.py:50[0m | ||
│ │ │ │ [8 frames hidden] [2mcollections, _abcoll, abc, _weakrefset[0m | ||
│ │ │ └─ [92m[2m0.077[0m [48;5;24m[38;5;15mproperties[0m [2mpywbem/cim_obj.py:2405[0m | ||
│ │ │ └─ [92m[2m0.072[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/_nocasedict.py:90[0m | ||
│ │ │ └─ [92m[2m0.066[0m __init__[0m [2mcollections.py:50[0m | ||
│ │ │ [8 frames hidden] [2mcollections, _abcoll, abc, _weakrefset[0m | ||
│ │ ├─ [92m[2m0.153[0m [48;5;24m[38;5;15m__setitem__[0m [2mpywbem/cim_obj.py:2635[0m | ||
│ │ │ └─ [92m[2m0.073[0m [48;5;24m[38;5;15m__setitem__[0m [2mpywbem/_nocasedict.py:232[0m | ||
│ │ └─ [92m[2m0.095[0m [48;5;24m[38;5;15mcheck_node[0m [2mpywbem/tupleparse.py:165[0m | ||
│ │ └─ [92m[2m0.069[0m [self][0m [2m[0m | ||
│ ├─ [32m0.405[0m [48;5;24m[38;5;15mparse_instancename[0m [2mpywbem/tupleparse.py:942[0m | ||
│ │ ├─ [92m[2m0.172[0m [48;5;24m[38;5;15mlist_of_various[0m [2mpywbem/tupleparse.py:302[0m | ||
│ │ │ └─ [92m[2m0.153[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ │ │ └─ [92m[2m0.132[0m [48;5;24m[38;5;15mparse_keybinding[0m [2mpywbem/tupleparse.py:1013[0m | ||
│ │ │ └─ [92m[2m0.098[0m [48;5;24m[38;5;15mone_child[0m [2mpywbem/tupleparse.py:250[0m | ||
│ │ │ └─ [92m[2m0.086[0m [48;5;24m[38;5;15mparse_any[0m [2mpywbem/tupleparse.py:2057[0m | ||
│ │ │ └─ [92m[2m0.069[0m [48;5;24m[38;5;15mparse_keyvalue[0m [2mpywbem/tupleparse.py:1034[0m | ||
│ │ └─ [92m[2m0.154[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/cim_obj.py:1102[0m | ||
│ │ └─ [92m[2m0.125[0m [48;5;24m[38;5;15mkeybindings[0m [2mpywbem/cim_obj.py:1252[0m | ||
│ │ └─ [92m[2m0.069[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/_nocasedict.py:90[0m | ||
│ └─ [32m0.268[0m [48;5;24m[38;5;15mpath[0m [2mpywbem/cim_obj.py:2499[0m | ||
│ └─ [32m0.264[0m [48;5;24m[38;5;15mcopy[0m [2mpywbem/cim_obj.py:1438[0m | ||
│ └─ [92m[2m0.244[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/cim_obj.py:1102[0m | ||
│ └─ [92m[2m0.199[0m [48;5;24m[38;5;15mkeybindings[0m [2mpywbem/cim_obj.py:1252[0m | ||
│ └─ [92m[2m0.080[0m [48;5;24m[38;5;15m__init__[0m [2mpywbem/_nocasedict.py:90[0m | ||
│ └─ [92m[2m0.061[0m __init__[0m [2mcollections.py:50[0m | ||
│ [8 frames hidden] [2mcollections, _abcoll, abc, _weakrefset[0m | ||
└─ [33m1.097[0m [48;5;24m[38;5;15mxml_to_tupletree_sax[0m [2mpywbem/tupletree.py:125[0m | ||
└─ [33m1.089[0m parseString[0m [2mxml/sax/__init__.py:35[0m | ||
[6 frames hidden] [2mxml[0m | ||
[33m1.087[0m feed[0m [2mxml/sax/expatreader.py:209[0m | ||
├─ [32m0.549[0m [48;5;24m[38;5;15mStartElement[0m [2m../../../../../private/tmp/python@2-20190212-94033-m4zuyi/Python-2.7.15/Modules/pyexpat.c:566[0m | ||
│ └─ [32m0.531[0m start_element[0m [2mxml/sax/expatreader.py:335[0m | ||
│ [4 frames hidden] [2mxml[0m | ||
│ [32m0.446[0m [48;5;24m[38;5;15mstartElement[0m [2mpywbem/tupletree.py:96[0m | ||
│ └─ [32m0.409[0m [self][0m [2m[0m | ||
├─ [92m[2m0.191[0m [48;5;24m[38;5;15mCharacterData[0m [2m../../../../../private/tmp/python@2-20190212-94033-m4zuyi/Python-2.7.15/Modules/pyexpat.c:441[0m | ||
│ └─ [92m[2m0.151[0m [48;5;24m[38;5;15mcharacters[0m [2mpywbem/tupletree.py:115[0m | ||
└─ [92m[2m0.116[0m [48;5;24m[38;5;15mEndElement[0m [2m../../../../../private/tmp/python@2-20190212-94033-m4zuyi/Python-2.7.15/Modules/pyexpat.c:618[0m | ||
└─ [92m[2m0.091[0m end_element[0m [2mxml/sax/expatreader.py:338[0m | ||
[2 frames hidden] [2mxml[0m | ||
|
||
|
||
Results: profile=pyinst, response_counts=[10000], | ||
response-sizes=[500], runid=12-nocasedict 20190302-165607 | ||
+------------+------------+------------+---------+--------------+-------------+ | ||
| Exp inst | Act inst | Response | XML | Parse time | Instances | | ||
| size | size | Count | size | sec. | per sec | | ||
+============+============+============+=========+==============+=============+ | ||
| 500 | 589 | 10000 | 5896919 | 5.33 | 1877 | | ||
+------------+------------+------------+---------+--------------+-------------+ |
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