Re: Two features I don't understand

2014-10-31 Thread Ali Lloyd
Regarding id caching, I had an idea that one might be able to use it to
emulate the performance gain of a 'repeat for each...' style structure on
controls.

Referencing a control by number or name will iterate through the controls
of the card until it gets to the specified one. Thus a loop of the form

repeat with x = 1 to the number of controls of this card
   // do something with control x
end repeat

could in theory be speed up by using

repeat for each line tId in the controlIDs of this card
   // do something with control id tID
end repeat


However I haven't yet tried to measure any actual performance difference,
and I think it would only be faster if there were a large number of
controls.

Ali

On 31 October 2014 04:48, Richard Gaskin ambassa...@fourthworld.com wrote:

 Monte Goulding wrote:
  On 31 Oct 2014, at 2:55 pm, Richard Gaskin wrote:
 
  If RunRev needed this themselves, they've done a good
  job of concealing why. :)  Copying styled text works
  great with htmlText.
 
  Richard if you remember originally styledText supported
  a few things that htmlText didn't and people complained...

 Rightly so, according to the inventor of the LiveCode engine:  Dr. Raney
 once explained to me that the purpose of htmlText is to provide an
 easily-manipulatable way to faithfully reproduce the entire contents and
 styles within a field or chunk.

 Anything less is indeed a bug report. :)

 I like the idea of using arrays to manipulate field contents, but alas we
 have so much missing from the the styledText representation at the moment.

 --
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for Desktop, Mobile, and Web
  
  ambassa...@fourthworld.comhttp://www.FourthWorld.com

 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your
 subscription preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Trevor DeVore
On Thu, Oct 30, 2014 at 2:36 PM, Richard Gaskin ambassa...@fourthworld.com
wrote:


 2. StyledText array
 Pages 16-18 of the v5.5.4 Release Notes:
 http://downloads.livecode.com/livecode/5_5_4/LiveCodeNotes-5_5_4.pdf

 Anyone here use this?  Is it faster than doing equivalent operations on
 htmlText?  While the style attributes themselves are well represented in
 the array, the character offsets of runs don't seem to be present, so I'm
 unclear as to what this should be used for.


Richard,

I use styled text all of the time in my text editors and exporters. Mainly
for modifying runs of text and for converting text to other formats. Two
examples:

1) Converting text to different types of markup. Markdown, BBCode, etc.
Looping through a styledText array makes it trivial to convert to other
text formats.

2) Modifying formatting in text. It is trivial to loop through the
styledtext array and strip out styles you don't want, add in metadata you
do want, etc. What if you want bold and italics but not color when the user
pastes text? The code is much simpler to write and easier to read using a
styledText array. It is much faster than looping through the text in a
field and checking styles.

-- 
Trevor DeVore
ScreenSteps
www.screensteps.com-www.clarify-it.com
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Michael Doub
I am sorry to report that the pageranges property of fields is still broken in 
7.0.  

Create a field and place this in a button:

on mouseUp
   put empty into fld 1
   set the height of fld 1 to 60
   repeat with i = 1 to 10
  put i  cr after fld 1
   end repeat
   set the spaceabove line 2 of fld 1 to 10
   put the pageranges of fld 1  cr
   put the first line should be 1,6 after msg
end mouseUp


On Oct 30, 2014, at 5:32 PM, Michael Doub miked...@gmail.com wrote:

 I use the styled arrays quite often when creating content, applying styles 
 and taking advantage of the metadata.  I can’t comment on the speed.
 
 I have a tendency to think in terms of arrays so this is pretty comfortable 
 for me.   
 
 I did a lot of work using space above and below and was really bummed when 
 pageranges did not take them into account.  (a bug report exists for this.)   
 I guess I should look and see if 7.0 addressed that issue.
 
 Rather than including char offsets for runs in the array itself, I think it 
 might be more useful to have an easy way to get from a char offset to the 
 pgh_number/run_number within the styled array.   Another thing to look at in 
 7.0.
 
 -= Mike
 
 
 On Oct 30, 2014, at 2:36 PM, Richard Gaskin ambassa...@fourthworld.com 
 wrote:
 
 1. ID caching
 Page 10 of the v6.0 Release Notes:
 http://downloads.livecode.com/livecode/6_0_0/LiveCodeNotes-6_0_0.pdf
 
 The description there says:
 
  The engine now caches lookups of control references of the form
  “card id ...” and “control id ...”.  This speeds up any access
  using those forms after the first time, turning an operation that
  would be completed in linear time into one that will be completed
  in constant time.
 
 What does that mean in practical terms?  How can I benchmark the benefit of 
 this new feature?
 
 
 2. StyledText array
 Pages 16-18 of the v5.5.4 Release Notes:
 http://downloads.livecode.com/livecode/5_5_4/LiveCodeNotes-5_5_4.pdf
 
 Anyone here use this?  Is it faster than doing equivalent operations on 
 htmlText?  While the style attributes themselves are well represented in the 
 array, the character offsets of runs don't seem to be present, so I'm 
 unclear as to what this should be used for.
 
 
 Any insight into either of these would be appreciated - TIA...
 
 -- 
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode
 

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Dr. Hawkins
On Thu, Oct 30, 2014 at 3:32 PM, Alex Tweedly a...@tweedly.net wrote:

 If I could remember well enough how to find things on Nabble or Gmane, I'd
 just point to the original thread - but since I can't and am in a hurry -
 here's a message I sent to this list on 12/05/2013.


There are *very* few sites who can search themselves as well as google.

So search for

 caching id site:nabble.com

or whathaveyou.  (actually, I tend to use -site:nabble.com when searching
for answers,as it usually only gives me parasitic duplicates of the
original thread.)


-- 
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Dr. Hawkins
On Thu, Oct 30, 2014 at 9:48 PM, Richard Gaskin ambassa...@fourthworld.com
wrote:


 Rightly so, according to the inventor of the LiveCode engine:  Dr. Raney
 once explained to me that the purpose of htmlText is to provide an
 easily-manipulatable way to faithfully reproduce the entire contents and
 styles within a field or chunk.

 Anything less is indeed a bug report. :)

 I like the idea of using arrays to manipulate field contents, but alas we
 have so much missing from the the styledText representation at the moment.


so does styledText even have a purpose any more?  Should it be treated as
deprecated?


-- 
Dr. Richard E. Hawkins, Esq.
(702) 508-8462
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Bob Sneidar
My guess would be data grids and anything using behaviors.

Bob S


On Oct 30, 2014, at 21:04 , Richard Gaskin 
ambassa...@fourthworld.commailto:ambassa...@fourthworld.com wrote:

What I find most remarkable is the way your benchmark makes the value of this 
ID caching seem rather trivial.

I trust this was a one-liner, as I can't imagine them spending much time 
optimizing something so very specialized and which takes so little execution 
time per iteration.

I wonder what prompted this one...perhaps something specific to the coding 
style of the person who wrote the Project Browser?

--
Richard Gaskin
Fourth World Systems
Software Design and Development for Desktop, Mobile, and Web

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread tbodine
The improved field control of LC 5.4 and 6.0 and up has been extremely useful
to me. I use StyledText Array in much the same way as Trevor -- applying
format changes. And metadata attached to field chunks is a great feature
that's very useful for educational content creators. 

Overall, the field control of LC is far more powerful than the fields
offered in Director and Flash (and probably other tools), so there are
competitive reasons to maintain and promote these features in LC. Once
RunRev finishes modernizing the audio-visual player controls across
platforms, LC will be an excellent multimedia authoring tool.

Tom Bodine



--
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/Two-features-I-don-t-understand-tp4685202p4685237.html
Sent from the Revolution - User mailing list archive at Nabble.com.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Alex Tweedly

On 31/10/2014 04:04, Richard Gaskin wrote:

Alex Tweedly wrote:

H - I said this once before :-) :-)


My apologies for the inconvenience.  I'd either missed it before or 
completely forgot about it, but the latter seems unlikely given how 
remarkable the post was:




Oh Richard - I even threw in 2 smiley faces so you would *know* I was 
teasing you :-)



in 5.5.3
name takes 830 ms while id takes only 250 ms

but in 6.0 (i.e. with id caching)
name takes 830 ms while id takes 5 ms

-- Alex.




What I find most remarkable is the way your benchmark makes the value 
of this ID caching seem rather trivial.


I trust this was a one-liner, as I can't imagine them spending much 
time optimizing something so very specialized and which takes so 
little execution time per iteration.


I wonder what prompted this one...perhaps something specific to the 
coding style of the person who wrote the Project Browser?



It is a trivial example - but the speed-up of 50X seems significant.

It's not just *the* most recent ID that is cached (at least according to 
a simple-minded test I did - see the original thread for details). It 
does appear that it speeds up access to a number of cached IDs. So if 
you had a lot of controls (Datagrid ??) and were doing something to them 
multiple times (scrolling?, fading in/out, ...) then maybe it would be 
noticeable, if not actually significant.


Anyway - this is one way to test it - whether or not you find it useful.
Probably worth adding it to the compare-engine-versions benchmark; I'll 
do that once a framework / sample of that happens.


--Alex.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Richard Gaskin

Dr. Hawkins wrote:
 so does styledText even have a purpose any more?  Should it
 be treated as deprecated?

It seems it serves a very different purpose than htmlText.  It's a new 
addition and folks find it useful, so I wouldn't expect it to be deprecated.



Trevor DeVore wroteL
 I use styled text all of the time in my text editors and exporters.
 Mainly for modifying runs of text and for converting text to other
 formats. Two examples:
 ...

Good stuff - thanks for that, Trevor.  I figured it was useful, I just 
needed to see how.




Ali Lloyd wrote:
 Regarding id caching, I had an idea that one might be able to use
 it to emulate the performance gain of a 'repeat for each...' style
 structure on controls.

 Referencing a control by number or name will iterate through the
 controls of the card until it gets to the specified one. Thus a
 loop of the form

 repeat with x = 1 to the number of controls of this card
   // do something with control x
 end repeat

 could in theory be speed up by using

 repeat for each line tId in the controlIDs of this card
   // do something with control id tID
 end repeat

 However I haven't yet tried to measure any actual performance
  difference, and I think it would only be faster if there were
 a large number of controls.

Alex's test suggests it needs a very large number of controls or a very 
high number of iterations, but being a performance fiend I certainly 
don't mind any optimizations that offer a speed boost, even a minor one.


I can appreciate why this is limited to IDs, because they're seldom 
modified, but since I so rarely use them I have to ask: has the team 
considered caching other control references, perhaps purging the cache 
when the control's name or number is modified?




Tom Bodine wrote:
 Overall, the field control of LC is far more powerful than the
 fields offered in Director and Flash (and probably other tools),
 so there are competitive reasons to maintain and promote these
 features in LC.

Amen to that, brother.  Hardly a week goes by that I don't hear, Wow - 
you can do that in LiveCode?  Cool!



--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Fraser Gordon

On 30 Oct 2014, at 18:36, Richard Gaskin ambassa...@fourthworld.com wrote:

 
 2. StyledText array
 Pages 16-18 of the v5.5.4 Release Notes:
 http://downloads.livecode.com/livecode/5_5_4/LiveCodeNotes-5_5_4.pdf
 
 Anyone here use this?  Is it faster than doing equivalent operations on 
 htmlText?  While the style attributes themselves are well represented in the 
 array, the character offsets of runs don't seem to be present, so I'm unclear 
 as to what this should be used for.
 

The array returned by the styledText property is as close to the field’s 
internal representation as its possible to get in script.

Internally, the field is structured somewhat like this(*):

- Field
- Paragraph 1
- Run 1
- Run 2
- Paragraph 2

and the styledText property is that structure in array form. (A “run” in this 
case is a block of text sharing the same styling attributes). It is also 
possible to set properties at the paragraph and field levels so these are also 
exported in the styledText.

The offsets aren’t stored because they are redundant with the contents of the 
array - Run 2 comes after Run 1 (and Paragraph 2 comes after Paragraph 1). 
Storing them would cause problems when the contents of any of the runs are 
updated.

In terms of comparisons with htmlText, styledText is more “raw” - far closer to 
the field’s internal representation than HTML. Because of this, it is easier 
for the field to process than HTML (especially as HTML has to be parsed while 
the array is already structured). Looking at it from the other side, an array 
is generally easier to manipulate compared to parsing HTML in your scripts.

There are definitely some very heavy users of the styledText in the LiveCode 
community; I know because the refactoring work for 7 broke it at various times 
during the DP process…

(*) the field is vastly more complicated than this diagram. For example, there 
are “lines” and “segments” used internally between paragraphs and runs in order 
to keep the code remotely manageable. It is by far the most complicated control 
in the engine and that was before adding support for things like bi-directional 
text input… the humble LiveCode field is actually not all that different from 
the insides of a word processor.

Fraser


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Richard Gaskin

Alex Tweedly wrote:

On 31/10/2014 04:04, Richard Gaskin wrote:

What I find most remarkable is the way your benchmark makes the value
of this ID caching seem rather trivial.

...

It is a trivial example - but the speed-up of 50X seems significant.


In relative terms it certainly seems so, but in absolute time just how 
much is being saved?  That is, what is the time required to resolve an 
object ID without caching?


This reminds me of a test I ran yesterday on a different issue, similar 
only in that whether or not it's a valuable thing to do may differ 
depending on whether you're looking at total-time or time-per-iteration:


I was measuring how much overhead is involved in making a call to a 
function relative to performing the same code in-line.


The total time saved was 15.897949 ms, which seems a worthy number until 
we consider that it was running for 100,000 iterations.


In a single iteration it was only saving 0.000159 ms, which for the 
purposes of the test made it clear that the performance penalty of 
factoring large handlers is probably not worth the time we spend trying 
to wrap our head around really long complex handlers.


With ID caching we have a nuance that further qualifies its value:  it's 
very specific, caching only ID references but not the more commonly-used 
forms like names or, as often used in loops, ordinal numbers.


That said, I tend to be somewhat obsessive about performance because I 
see every nanosecond saved as a penny in a bank account; over time I can 
save up enough to have some milliseconds free to spend on new features 
like real-time display updates or background processing.


So I'm always grateful for anything that boosts performance in the 
engine, even those that may seem small, since over the long run 
everything adds up.




Probably worth adding it to the compare-engine-versions benchmark; I'll
do that once a framework / sample of that happens.


I hope we can get that project going.  It'll be very helpful for many 
purposes.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-31 Thread Richard Gaskin
Always valuable to read your words here, Fraser.  Meeting you was one of 
the key highlights for me at the conference.


You wrote:

 Internally, the field is structured somewhat like this(*):

 - Field
- Paragraph 1
- Run 1
- Run 2
- Paragraph 2

 and the styledText property is that structure in array form. (A “run” 
 in this case is a block of text sharing the same styling attributes).

 It is also possible to set properties at the paragraph and field
 levels so these are also exported in the styledText.

 The offsets aren’t stored because they are redundant with the
 contents of the array - Run 2 comes after Run 1 (and Paragraph 2
 comes after Paragraph 1). Storing them would cause problems when
 the contents of any of the runs are updated.
 ...
 (*) the field is vastly more complicated than this diagram. For
 example, there are “lines” and “segments” used internally between
 paragraphs and runs in order to keep the code remotely manageable.

This is one of the things that had eluded me about this feature originally:

I had been looking at StyledText as a means of setting attributes, very 
useful for setting at the field or paragraph level, but without offsets 
not so much for making a single word within a paragraph bold, for example.


But I see now that most folks are using it as read-only, for exporters. 
 I can definitely see very high value in that - in fact, I'm tempted 
now to rewrite some exporters I have to make use of this over htmlText 
as I had been using.



 It is by far the most complicated control in the engine and that
 was before adding support for things like bi-directional text input…
 the humble LiveCode field is actually not all that different from
 the insides of a word processor.

Agreed.  I think Kevin was being modest:
http://lists.runrev.com/pipermail/use-livecode/2012-February/168802.html

In terms of the full scope of features a true word processor needs to 
compete against Microsoft I think he has a good point there, but in the 
broader view of being able to craft very specialized word processing 
tools I think LiveCode is perhaps the most capable development option on 
the planet.



This is good to know:

 In terms of comparisons with htmlText, styledText is more “raw” -
 far closer to the field’s internal representation than HTML.
 Because of this, it is easier for the field to process than HTML
 (especially as HTML has to be parsed while the array is already
 structured). Looking at it from the other side, an array is generally
 easier to manipulate compared to parsing HTML in your scripts.

Thanks for your input, Fraser.  And thanks to Trevor, Tom, and the 
others who've provided good examples of styledText in use.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Two features I don't understand

2014-10-31 Thread Bob Sneidar
That settles it. Richard Gaskin is an Alien Android!!

Bob S


On Oct 31, 2014, at 10:40 , Richard Gaskin 
ambassa...@fourthworld.commailto:ambassa...@fourthworld.com wrote:

That said, I tend to be somewhat obsessive about performance because I see 
every nanosecond saved as a penny in a bank account; over time I can save up 
enough to have some milliseconds free to spend on new features like real-time 
display updates or background processing.

So I'm always grateful for anything that boosts performance in the engine, even 
those that may seem small, since over the long run everything adds up.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Two features I don't understand

2014-10-30 Thread Richard Gaskin

1. ID caching
Page 10 of the v6.0 Release Notes:
http://downloads.livecode.com/livecode/6_0_0/LiveCodeNotes-6_0_0.pdf

The description there says:

   The engine now caches lookups of control references of the form
   “card id ...” and “control id ...”.  This speeds up any access
   using those forms after the first time, turning an operation that
   would be completed in linear time into one that will be completed
   in constant time.

What does that mean in practical terms?  How can I benchmark the benefit 
of this new feature?



2. StyledText array
Pages 16-18 of the v5.5.4 Release Notes:
http://downloads.livecode.com/livecode/5_5_4/LiveCodeNotes-5_5_4.pdf

Anyone here use this?  Is it faster than doing equivalent operations on 
htmlText?  While the style attributes themselves are well represented in 
the array, the character offsets of runs don't seem to be present, so 
I'm unclear as to what this should be used for.



Any insight into either of these would be appreciated - TIA...

--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Two features I don't understand

2014-10-30 Thread Michael Doub
I use the styled arrays quite often when creating content, applying styles and 
taking advantage of the metadata.  I can’t comment on the speed.

I have a tendency to think in terms of arrays so this is pretty comfortable for 
me.   

I did a lot of work using space above and below and was really bummed when 
pageranges did not take them into account.  (a bug report exists for this.)   I 
guess I should look and see if 7.0 addressed that issue.

Rather than including char offsets for runs in the array itself, I think it 
might be more useful to have an easy way to get from a char offset to the 
pgh_number/run_number within the styled array.   Another thing to look at in 
7.0.

-= Mike


On Oct 30, 2014, at 2:36 PM, Richard Gaskin ambassa...@fourthworld.com wrote:

 1. ID caching
 Page 10 of the v6.0 Release Notes:
 http://downloads.livecode.com/livecode/6_0_0/LiveCodeNotes-6_0_0.pdf
 
 The description there says:
 
   The engine now caches lookups of control references of the form
   “card id ...” and “control id ...”.  This speeds up any access
   using those forms after the first time, turning an operation that
   would be completed in linear time into one that will be completed
   in constant time.
 
 What does that mean in practical terms?  How can I benchmark the benefit of 
 this new feature?
 
 
 2. StyledText array
 Pages 16-18 of the v5.5.4 Release Notes:
 http://downloads.livecode.com/livecode/5_5_4/LiveCodeNotes-5_5_4.pdf
 
 Anyone here use this?  Is it faster than doing equivalent operations on 
 htmlText?  While the style attributes themselves are well represented in the 
 array, the character offsets of runs don't seem to be present, so I'm unclear 
 as to what this should be used for.
 
 
 Any insight into either of these would be appreciated - TIA...
 
 -- 
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com
 
 ___
 use-livecode mailing list
 use-livecode@lists.runrev.com
 Please visit this url to subscribe, unsubscribe and manage your subscription 
 preferences:
 http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-30 Thread Alex Tweedly

On 30/10/2014 18:36, Richard Gaskin wrote:

1. ID caching
Page 10 of the v6.0 Release Notes:
http://downloads.livecode.com/livecode/6_0_0/LiveCodeNotes-6_0_0.pdf

The description there says:

   The engine now caches lookups of control references of the form
   “card id ...” and “control id ...”.  This speeds up any access
   using those forms after the first time, turning an operation that
   would be completed in linear time into one that will be completed
   in constant time.

What does that mean in practical terms?  How can I benchmark the 
benefit of this new feature?



H - I said this once before :-) :-)

If I could remember well enough how to find things on Nabble or Gmane, 
I'd just point to the original thread - but since I can't and am in a 
hurry - here's a message I sent to this list on 12/05/2013.






Yes, here's an example. The clue (I think) is in the linear 
time...into constant time


Create a large-ish number of controls - in this stack I cloned a 
button 1000 times, calling them

BBB1   BBB2  BBB1000

Then this code accesses a single control many times - and shows that 
accessing by id is much faster than accessing by name, but more 
importantly here, that in 6.0 access by id to the most recently 
accessed control is very fast.


in 5.5.3
name takes 830 ms while id takes only 250 ms

but in 6.0 (i.e. with id caching)
name takes 830 ms while id takes 5 ms

-- Alex.



global K

on mouseUp
   put 1000 into K

   put the millisecs into t1
   put BBB(K-10) into tName
   repeat 1 times
  put the short name of control tName  into t
   end repeat
   put the millisecs-t1  t CR after msg

   put the millisecs into t1
   put the id of button tName into tID
   repeat 1 times
  put the short name of control id tID  into t
   end repeat
   put the millisecs-t1  t CR after msg

end mouseUp



On 11/05/2013 03:11, Richard Gaskin wrote:
The Release Notes for v6 include:

  ID caching (6.0 DP 2)
  New global property – allowDatagramBroadcasts (6.0 DP 2)
  A new global property allowDatagramBroadcasts has been added. This
  needs to be set to true before sending to a broadcast address
  (enables the per-socket flag for whether they are allowed).
  The engine now caches lookups of control references of the form
  “card id ...” and “control id ...”.
  This speeds up any access using those forms after the first time,
  turning an operation that would be completed in linear time into
  one that will be completed in constant time.


I'm not clear on the syntax, so I've been unable to benchmark the 
performance boost.


Anyone here have a sample of ID caching in action?

--
 Richard Gaskin
 Fourth World
 LiveCode training and consulting: http://www.fourthworld.com
 Webzine for LiveCode developers: http://www.LiveCodeJournal.com
 Follow me on Twitter: http://twitter.com/FourthWorldSys

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode 



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Two features I don't understand

2014-10-30 Thread Richard Gaskin

Michael Doub wrote:

 I use the styled arrays quite often when creating content, applying
 styles and taking advantage of the metadata.

Thanks.  I still don't understand how I might use it, but I'm glad 
someone's using it.


RunRev don't generally spend time on a feature unless there's either a 
lot of people asking for it or it's something they need themselves.


Since AFAIK no one's ever asked for this it seems an internal need, but 
the examples in the Dictionary are a bit weak, simply using it to copy 
formatted content but nothing more interesting than that.


If RunRev needed this themselves, they've done a good job of concealing 
why. :)  Copying styled text works great with htmlText.



 Rather than including char offsets for runs in the array itself,
 I think it might be more useful to have an easy way to get from
 a char offset to the pgh_number/run_number within the styled array.
 Another thing to look at in 7.0.

Yes, when I first heard about StyledText I had imagined it would have 
elements like that, which would make it much more interesting (or at 
least understandable) for me.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for Desktop, Mobile, and Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-30 Thread Richard Gaskin

Alex Tweedly wrote:

On 30/10/2014 18:36, Richard Gaskin wrote:

1. ID caching
Page 10 of the v6.0 Release Notes:
http://downloads.livecode.com/livecode/6_0_0/LiveCodeNotes-6_0_0.pdf

The description there says:

   The engine now caches lookups of control references of the form
   “card id ...” and “control id ...”.  This speeds up any access
   using those forms after the first time, turning an operation that
   would be completed in linear time into one that will be completed
   in constant time.

What does that mean in practical terms?  How can I benchmark the
benefit of this new feature?


H - I said this once before :-) :-)


My apologies for the inconvenience.  I'd either missed it before or 
completely forgot about it, but the latter seems unlikely given how 
remarkable the post was:



Yes, here's an example. The clue (I think) is in the linear
time...into constant time

Create a large-ish number of controls - in this stack I cloned a
button 1000 times, calling them
BBB1   BBB2  BBB1000

Then this code accesses a single control many times - and shows that
accessing by id is much faster than accessing by name, but more
importantly here, that in 6.0 access by id to the most recently
accessed control is very fast.

in 5.5.3
name takes 830 ms while id takes only 250 ms

but in 6.0 (i.e. with id caching)
name takes 830 ms while id takes 5 ms

-- Alex.



global K

on mouseUp
   put 1000 into K

   put the millisecs into t1
   put BBB(K-10) into tName
   repeat 1 times
  put the short name of control tName  into t
   end repeat
   put the millisecs-t1  t CR after msg

   put the millisecs into t1
   put the id of button tName into tID
   repeat 1 times
  put the short name of control id tID  into t
   end repeat
   put the millisecs-t1  t CR after msg

end mouseUp


What I find most remarkable is the way your benchmark makes the value of 
this ID caching seem rather trivial.


I trust this was a one-liner, as I can't imagine them spending much time 
optimizing something so very specialized and which takes so little 
execution time per iteration.


I wonder what prompted this one...perhaps something specific to the 
coding style of the person who wrote the Project Browser?


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for Desktop, Mobile, and Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Re: Two features I don't understand

2014-10-30 Thread Monte Goulding

On 31 Oct 2014, at 2:55 pm, Richard Gaskin ambassa...@fourthworld.com wrote:

 If RunRev needed this themselves, they've done a good job of concealing why. 
 :)  Copying styled text works great with htmlText.

Richard if you remember originally styledText supported a few things that 
htmlText didn't and people complained so they upgraded htmlText so I think the 
original plan was to introduce a way to work with the new field features and 
that may have become somewhat redundant after the update to htmlText. I think 
it also mirrors more closely the data structures used in the engine and 
therefore be a bit quicker to get and set.

Cheers

--
M E R Goulding 
Software development services
Bespoke application development for vertical markets

mergExt - There's an external for that!

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Two features I don't understand

2014-10-30 Thread Richard Gaskin

Monte Goulding wrote:
 On 31 Oct 2014, at 2:55 pm, Richard Gaskin wrote:

 If RunRev needed this themselves, they've done a good
 job of concealing why. :)  Copying styled text works
 great with htmlText.

 Richard if you remember originally styledText supported
 a few things that htmlText didn't and people complained...

Rightly so, according to the inventor of the LiveCode engine:  Dr. Raney 
once explained to me that the purpose of htmlText is to provide an 
easily-manipulatable way to faithfully reproduce the entire contents and 
styles within a field or chunk.


Anything less is indeed a bug report. :)

I like the idea of using arrays to manipulate field contents, but alas 
we have so much missing from the the styledText representation at the 
moment.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for Desktop, Mobile, and Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode