HC Music that should be on Runtime Revolution

J. Landman Gay jacque at hyperactivesw.com
Tue Mar 17 20:04:56 EDT 2009


Colin Holgate wrote:

> For what I was trying, playing a whole tune, I would only need the data 
> once. Did you try my script? Does it not work fast for you too?

Oh yes, for single-use access a field is plenty fast enough.

> 
> As for fields being slower than customproperties, it seems that may not 
> be true, at least in the case of text. Try this script, after putting 
> some text in the field (I had just over 7k):
> 
> set the customproperties of player 1 to field 1
> put the ticks into t
> repeat with a = 1 to 1000000
> get field 1
> end repeat
> put the ticks - t into t1
> put the ticks into t
> repeat with a = 1 to 100000
> get the properties of player 1
> end repeat
> put t1 && the ticks - t
> 
> The figures I got were 198 and 325 ticks. If I was arguing that fields 
> was a bit faster, then 198 to 325 would prove that. But note that the 
> routine gets the text from the field a million times, and only gets the 
> customproperties 100,000 times. You can try the customproperties a 
> million times too, but you'll think your machine has crashed.
> 
> So, at least in this case retrieving from a field is about 1,600 times 
> as fast as retrieving from customproperties, and retrieving once from a 
> field is taking about 3.3 microseconds. That's close enough to 
> instantaneous for me.

The test isn't quite right. The script isn't getting a custom property 
but rather retrieves a whole list of object properties, which is a 
different thing. For the above script, like you, I get 490 and 544 ticks 
respectively (my span isn't as wide as yours.) But it is apples and oranges.

A better test is this:

    set the myProp of btn 1 to field 1 -- assigns custom property
    put the ticks into t
    repeat with a = 1 to 1000000
       get field 1
    end repeat
    put the ticks - t into t1
    put the ticks into t
    repeat with a = 1 to 100000
       get the myProp of btn 1
    end repeat
    put t1 && the ticks - t

This assigns a single custom property called "myProp" to button 1, which 
contains the same data as the test field. It then runs the same test 
repeat loops, except that it retrieves the actual custom property value 
rather than a list of all the button's properties (I used a button, but 
a player or any object should yield the same results.)

In this test, I get 490 ticks for field retrieval and 25 ticks for 
custom property retrieval.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the Use-livecode mailing list