Friday, June 3, 2011

Discovering Metrics about Parsley and creating its context

Recently I had a performance tuning need to figure out how long Parsley was taking to instantiate and create its context. Thanks to Marty Pitt for the solution.

First off within the main application have the following when you are defining your context


<parsley:ContextBuilder complete="applicationContextBuilderComplete(event)">
   <debug:TimedObjectSupport />
   <parsley:ViewProcessor type="{ExtendedViewProcessor}" />
</parsley:ContextBuilder>


protected function applicationContextBuilderComplete(event:FlexContextEvent):void
   {
    trace ("Processing Parsley Context: stopTime > " + getTimer());
   }

Where TimedObjectSupport.as is:

import org.spicefactory.parsley.core.bootstrap.BootstrapConfig;
import org.spicefactory.parsley.flex.tag.builder.BootstrapConfigProcessor;

public class TimedObjectSupport implements BootstrapConfigProcessor
 {
  public function processConfig(config:BootstrapConfig):void
  {
   trace ("Processing Parsley Context: startTime > " + getTimer());
  }
 }

and ExtendedViewProcessor.as is:

import org.spicefactory.parsley.core.context.Context;
 import org.spicefactory.parsley.core.view.ViewConfiguration;
 import org.spicefactory.parsley.core.view.processor.DefaultViewProcessor;
 
 public class ExtendedViewProcessor extends DefaultViewProcessor
 {
  public override function init(config:ViewConfiguration, context:Context):void
  {
   trace("Parsley Wiring Start-> " +getTimer());
    super.init(config,context);
   trace("Parsley Wiring Stop-> " +getTimer());
  }


 }

No comments:

Post a Comment