|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Mon Dec 24, 2007 4:16 am
[2.18] %dbvalues, %word, and hash table building |
I would expect some speed differences between these various things but the results from this test are very bad.
1. Launch CMud
2. Close Sessions window (ESC)
3. Enter at the command line
Code: |
$a=%secs;$var="test|abc=""def|ghi|jkl""";#LOOP 10000 {#CALL %dbvalues($var)};#SHOW $var %dbvalues($var) (%secs-$a) |
On my system this comes back in about 1600ms, repeat as needed to establish a good time.
4. Enter at the command line
Code: |
$a=%secs;$var="test|abc=""def|ghi|jkl""";#ADDKEY $var;#LOOP 10000 {#CALL %dbvalues($var)};#SHOW $var %dbvalues($var) (%secs-$a) |
On my system this is about 465ms, again repeat as need. Now we see this second one has built the hash table, while the first one didn't. Now I thought building the hash table and converting it back to a string was supposed to take much longer then doing a string comparison. Is %dbvalues building it every single time and returning the string comparison result?
5. Enter at the command line
Code: |
$a=%secs;$var="test|abc=""def|ghi|jkl""";#LOOP 10000 {#CALL %word($var,2,"=")};#SHOW $var %word($var,2,"=") (%secs-$a) |
This comes up at 560ms on my system. Much better then that 1600 from 3.
6. Enter at the command line
Code: |
$a=%secs;$var="test|abc=""def|ghi|jkl""";#ADDKEY $var;#LOOP 10000 {#CALL %($var,2,"=")};#SHOW $var %word($var,2,"=") (%secs-$a) |
Now I get a time of 570ms. Obviously rebuilding the string for %word to use is still taking less time then the first %dbvalues test. We also now see a bug in the results from %word, where did the |test get to? The display of $var on both tests with #ADDKEY clearly shows that the 'test' key ends up later.
So 2 bugs: %dbvalues takes way too long when it is passed a string, and %word loses everything after a pair of quotes. |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Jan 07, 2008 11:29 pm |
I'll look into this. I know that %word has a bug in some cases and this might be related.
As far as the speed, you are storing a literal string to the $var local variable (because you have " quotes around the list). So no hash table is built until you use a command or function that builds the hash table and converts the literal string into a string list.
#ADDKEY performs this conversion, which is why (4) is faster than (3). %dbvalues will create a hash table internally, but it will not automatically convert the "type" of the $var variable from a literal string to a string list. The #ADDKEY command *does* change the type of $var to a string list. The weird part is that I don't know why step (5) is running fast since %word shouldn't be changing the type of $var either. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|