View Single Post
09-28-11, 05:35 AM   #10
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2005
Posts: 793
This is what I found, obviously the built in code handles it much faster.

The code I used: http://pastebin.com/Xfc2wgpF

1. There are over 10k names and the code picks 1/10th random names from the whole table, and makes sure they are not duplicates.
2. The function runs, either method 1 or 2, (1) find by key (2) traverse and match.
3. They return the time the finding of the names took, i.e. not the whole but only the matching parts that found the names in the huge table(s).
4. The times are compared and printed, the print lines while the tests ran are rounded down so not accurate, the final number is on the other hand.

Code:
[13:31:18] [1] 6810.301 to 6810.301 (0.000 ms) - 1024/1024 of 10239
[13:31:18] [1] 6810.301 to 6810.301 (0.000 ms) - 1024/1024 of 10239
[13:31:18] [1] 6810.301 to 6810.301 (0.000 ms) - 1024/1024 of 10239
[13:31:18] [1] 6810.301 to 6810.317 (0.016 ms) - 1024/1024 of 10239
[13:31:18] [1] 6810.317 to 6810.317 (0.000 ms) - 1024/1024 of 10239
[13:31:18] [1] 6810.317 to 6810.317 (0.000 ms) - 1024/1024 of 10239
[13:31:18] [1] 6810.317 to 6810.317 (0.000 ms) - 1024/1024 of 10239
[13:31:18] [1] 6810.317 to 6810.317 (0.000 ms) - 1024/1024 of 10239
[13:31:18] [1] 6810.317 to 6810.317 (0.000 ms) - 1024/1024 of 10239
[13:31:18] [1] 6810.317 to 6810.317 (0.000 ms) - 1024/1024 of 10239
[13:31:18] test1: 0.0015999999999622 ms
[13:31:26] [2] 6817.181 to 6817.883 (0.702 ms) - 1024/1024 of 10239
[13:31:26] [2] 6817.961 to 6818.663 (0.702 ms) - 1024/1024 of 10239
[13:31:27] [2] 6818.741 to 6819.427 (0.686 ms) - 1024/1024 of 10239
[13:31:28] [2] 6819.505 to 6820.207 (0.702 ms) - 1024/1024 of 10239
[13:31:29] [2] 6820.285 to 6820.972 (0.687 ms) - 1024/1024 of 10239
[13:31:29] [2] 6821.050 to 6821.752 (0.702 ms) - 1024/1024 of 10239
[13:31:30] [2] 6821.830 to 6822.532 (0.702 ms) - 1024/1024 of 10239
[13:31:31] [2] 6822.610 to 6823.296 (0.686 ms) - 1024/1024 of 10239
[13:31:32] [2] 6823.374 to 6824.060 (0.686 ms) - 1024/1024 of 10239
[13:31:33] [2] 6824.138 to 6824.856 (0.718 ms) - 1024/1024 of 10239
[13:31:33] test2: 0.69730000000009 ms
Traversing used 0.6973 ms while using the table key used only 0.0016 ms. So with a lot of data it's more efficient to find using keys, rather than traversing and matching, really.

Last edited by Vlad : 09-28-11 at 05:41 AM.
  Reply With Quote