Overview
| Artifact ID: | 032ffa502c242ca6bd773ff52042cd4d64accb23 |
|---|---|
| Ticket: | 2318906fffffffffffffffffffffffffffffffff
order of insertion seems to have large performance impact |
| User & Date: | nijtmans on 2008-11-21 13:50:59 |
Changes
- icomment:
I don't think this is a bug. In the code above, every "dict set" has to search two keys in two hash tables. Separating the "key2" stuff, means you only have to seach one key for each "dict set", and only do a single search for "key2". A hash search depends much on the size of the hash table, but small hash-tables are relatively inefficient. It is simply the nature of hash-tables. Running your code: $ tclsh85 dict_test.tcl fast method. 1000 lines done. 2000 lines done. 3000 lines done. 4000 lines done. 5000 lines done. lines: 5000 filelines: 3267 commitlines: 1733 elapsed: 0 slow method. 1000 lines done. 2000 lines done. 3000 lines done. 4000 lines done. 5000 lines done. lines: 5000 filelines: 3267 commitlines: 1733 elapsed: 1 That's fast, less than 1 second. Even when changing "clock seconds" to "clock milliseconds", the answer is the same, which means that it is less than the resolution of the windows clock (something like 1/15 sec) Collecting the "key2" stuff into a separate dict is indeed a good optimization. Regards, Jan Nijtmans - login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"