To expand on Jude's answer below, DataGrid and item renderers do not
require data binding unless the field in the data objects are going to
change after the user is viewing it in the DataGrid and you need the
renderer to update immediately.

If that isn't the case, then there is no need for Bindable data objects
and plain objects will work just fine although a data class of vars will
be even faster.

If you write your renderers in MXML, then as Jude says, the temptation is
to use data binding, but you can almost always replace that by using code
in the dataChange event handler, or better yet, write the renderer in AS
instead of MXML and avoid a whole bunch of other code you don't need.

So if you had an MXML item renderer:

<mx:Container>
  <mx:Label id="foo" text="{data.property}" />
</mx:Container>

As Jude says, this is faster and won't require ObjectProxy or [Bindable]:
<mx:Container dataChange="foo.txt = data.property">
  <mx:Label id="foo" />
</mx:Container>

But not using Container and using ActionScript will be even faster,
although this won't affect your loop time.
Public class MyRenderer extends UIComponent implements
IDataGridItemRenderer
{
  override protected function createChildren()
  {
    foo = new Label();
  }

  public function set data(value:Object):void
  {
    foo.text = data.property;
  }

  ... More code needed ...
}

But we still want to know how you can run this loop for so long without
hitting the script timeout.  I suspect you are doing some sort of pseudo
threading and doing chunks of the loop on every frame.  If not, you should
think about doing so and displaying a progress indicator for the user.
Workers may still cut down the time after all of these optimizations, but
you may have reached the point where it isn't worth it.

-Alex

On 8/2/16, 12:26 AM, "jude" <flexcapaci...@gmail.com> wrote:

>If you're using object proxies or viable objects for bindings specifically
>for use in ItemRenderers that could be taking plenty of time as well.
>
>Instead, override the set data function of the Item Renderer and set the
>component properties directly and do not use binding tags in the MXML.
>
>Example:
>
>myLabel.text = data.myProperty;
>
>versus:
>
><s:Label text="{data.myPrperty}" />
>
>P.S. How are you able to run a function that long? Script timeout limit
>max
>is set for one minute.
>
>See
>http://help.adobe.com/en_US/flex/using/WS77c1dbb1bd80d3836ecbb5ec129ec77b1
>e1-8000.html#WS5ED0A932-BA59-4a77-9A9D-3745FE21D1E9
>
>On Aug 2, 2016 1:46 AM, "Alex Harui" <aha...@adobe.com> wrote:
>
>That makes me want to ask a potentially important question:  Does this
>data need to be bindable in the first place?  Is MXML data binding being
>used on the data and/or are any of the properties in the data being
>changed and change events are needed?
>
>If not, then even using [Bindable] may not be necessary.
>
>Roughly speaking, if you have:
>
>public class Data
>{
>  public var field:int;
>}
>
>Then accessing the field variable is a simple and very fast memory lookup.
>
>But if you use [Bindable] then accessing the field variable essentially
>calls a function to get the value.
>
>function get field():int {
>  return _field;
>}
>
>And if you use ObjectProxy, then accessing field runs all of this code:
>
>override flash_proxy function getProperty(name:*):*
>    {
>        // if we have a data proxy for this then
>        var result:*;
>
>        if (notifiers[name.toString()])
>            return notifiers[name];
>
>        result = _item[name];
>
>        if (result)
>        {
>            if (_proxyLevel == 0 || ObjectUtil.isSimple(result))
>            {
>                return result;
>            }
>            else
>            {
>                result = object_proxy::getComplexProperty(name, result);
>            } // if we are proxying
>        }
>
>        return result;
>    }
>
>
>In some cases, it might be faster to convert from data objects that have
>[Bindable] to data objects of all vars. YMMV.
>
>HTH,
>-Alex
>
>On 8/1/16, 11:31 PM, "Christofer Dutz" <christofer.d...@c-ware.de> wrote:
>
>>Well the optimizations I did in order to get my applications to speed up
>>dramatically were on the one side using Arrays instead of collections.
>>The biggest thing I noticed were, that per default my model classes were
>>annotated with [Bindable], which caused every property to be bindable. By
>>explicitly handing the events and not relying on a bindable model, I cut
>>the overhead by 9/10th ... could check this (Have to admit that I haven't
>>read all of this lengthy thread though ... so if I'm suggesting something
>>that's already been suggested ... sorry for that ;-) )
>>
>>
>>Chris
>>
>>________________________________
>>Von: bilbosax <waspenc...@comcast.net>
>>Gesendet: Dienstag, 2. August 2016 07:24:17
>>An: users@flex.apache.org
>>Betreff: Re: Workers and Speed
>>
>>Alright!!!  Now we are getting somewhere! Passing the ArrayCollection to
>>a
>>standard Array cut the time in Half!  From almost 50 minutes down to 23
>>minutes.  So here is the breakdown now:
>>
>>Total time = 1396 sec
>>ObjectProxy.getProperty --> 804 sec
>>Garbarge Collection --> 198 sec
>>ObjectProxy.setProperty --> 25 sec
>>(times related to the ArrayCollection previously are gone!)
>>
>>I wish there was a way to get rid of some of that ObjectProxy time.
>>Regardless of it is is an object or an objectproxy or a bindable named
>>class, there is still going to be some time involved in plucking the data
>>out of the array to work on.  I don't know how severe of a penalty it is
>>that the data is inside of an ObjectProxy.  But I also don't understand
>>how
>>to use the bindable named class either.
>>
>>The way that it works is I am reading ALL of the data from a database
>>(SELECT * FROM main), and making the results the source of my
>>mainArrayCollection that displays in my datagrid and is used in all of my
>>calculations.  I don't know how to go about taking that data and
>>assigning
>>it to a bindable class.  Taking each object and converting it to an
>>objectproxy was a really easy process.  If you think that it would help
>>my
>>speed problems, could you help me to understand how to use this bindable
>>class that you and Alex have referred to?
>>
>>Thanks for all of your help!!!  I've gone from over 2 hours down to 23
>>minutes!
>>
>>
>>
>>
>>
>>
>>--
>>View this message in context:
>>http://apache-flex-users.2333346.n4.nabble.com/Workers-and-Speed-tp13098p
>>1
>>3140.html
>>Sent from the Apache Flex Users mailing list archive at Nabble.com.

Reply via email to