Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Piers Cowburn
How unfortunate. Although it doesn't really make that much difference in this 
scenario.

On 27 Dec 2009, at 16:15, Paul Andrews wrote:

> Henrik Andersson wrote:
>> Paul Andrews wrote:
>>> Piers Cowburn wrote:
>>> I think the compiler is still seeing the typed Vector as Vector, not
>>> typed vectors. Consequently a lookup is still involved. The
>>> Vector. declaration seems more of a syntactic convenience
>>> rather than anything else.
>>> 
>>> That's just guesswork on my part.
>>> 
>>> Paul
>> 
>> The compiler most definitively uses different opcodes for vectors, so it is 
>> not just a syntax convenience.
> Well, I would expect it to use different code for Vectors, but the code 
> generation may not be clever enough to look up the method associated with the 
> class reference for a given item, but will look up the method reference at 
> runtime.
> 
> Paul
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> 
> 
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Paul Andrews

Henrik Andersson wrote:

Paul Andrews wrote:

Piers Cowburn wrote:
I think the compiler is still seeing the typed Vector as Vector, not
typed vectors. Consequently a lookup is still involved. The
Vector. declaration seems more of a syntactic convenience
rather than anything else.

That's just guesswork on my part.

Paul


The compiler most definitively uses different opcodes for vectors, so 
it is not just a syntax convenience.
Well, I would expect it to use different code for Vectors, but the code 
generation may not be clever enough to look up the method associated 
with the class reference for a given item, but will look up the method 
reference at runtime.


Paul

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Paul Andrews

Piers Cowburn wrote:

Yeah, I was thinking along those lines. However, it's interesting that in tests 
Vector 0a vs Vector 1a, the implicit cast is still faster than using [ ] to 
access the reference directly from the vector. You'd think that with the vector 
being typed as TestClass, vector[i].someMethod() should be faster than var 
reference:TestClass = vector[i]; reference.someMethod()
  
I think the compiler is still seeing the typed Vector as Vector, not 
typed vectors. Consequently a lookup is still involved. The 
Vector. declaration seems more of a syntactic convenience 
rather than anything else.


That's just guesswork on my part.

Paul

Unless you were then going to use the reference again, in which case storing a 
temporary reference will always be faster. But for a one time look up from a 
typed vector, I'm surprised that two lines of code executes faster than one. I 
was wondering whether there might be something wrong with my test, but I can't 
see anything.

Piers
  

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Henrik Andersson

Paul Andrews wrote:

Piers Cowburn wrote:
I think the compiler is still seeing the typed Vector as Vector, not
typed vectors. Consequently a lookup is still involved. The
Vector. declaration seems more of a syntactic convenience
rather than anything else.

That's just guesswork on my part.

Paul


The compiler most definitively uses different opcodes for vectors, so it 
is not just a syntax convenience.

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Piers Cowburn
Yeah, I was thinking along those lines. However, it's interesting that in tests 
Vector 0a vs Vector 1a, the implicit cast is still faster than using [ ] to 
access the reference directly from the vector. You'd think that with the vector 
being typed as TestClass, vector[i].someMethod() should be faster than var 
reference:TestClass = vector[i]; reference.someMethod()

Unless you were then going to use the reference again, in which case storing a 
temporary reference will always be faster. But for a one time look up from a 
typed vector, I'm surprised that two lines of code executes faster than one. I 
was wondering whether there might be something wrong with my test, but I can't 
see anything.

Piers



On 27 Dec 2009, at 14:05, Paul Andrews wrote:

> Piers Cowburn wrote:
>> Cool, looks like the implicit cast is faster across the board, and almost 
>> twice as fast as just using the array access operator.
>>  
> For an object of a known class, I think the compiler is just referring 
> directly to the method rather than looking it up. When a method is invoked on 
> an abstract object it has to look at the class info for the object to locate 
> the method AT RUNTIME - hence the overhead. When the class is known it can 
> call the method directly without a runtime lookup.
> 
> In the case  of the explicit cast, I would expect that the cast is pointless 
> and adding needless overhead since the method reference is using the method 
> lookup at compile time from the variable, not from the cast. The cast adds 
> needless overhead at run time.
> 
> Paul
>> 
>> On 27 Dec 2009, at 13:13, Cor wrote:
>> 
>>  
>>> With this, my results are:
>>> Starting tests...
>>> [Array 0a] Array access test: 462
>>> [Array 1a] Implicit cast test: 258
>>> [Array 2a] Explicit cast test: 406
>>> [Array 3a] As cast test: 429
>>> [Array 0b] Array access test (two operations): 1062
>>> [Array 1b] Implicit cast test (two operations): 477
>>> [Array 2b] Explicit cast test (two operations): 647
>>> [Array 3b] As cast test (two operations): 652
>>> [Vector 0a] Vector access test: 458
>>> [Vector 1a] Implicit cast test: 252
>>> [Vector 2a] Explicit cast test: 402
>>> [Vector 3a] As cast test: 425
>>> [Vector 0b] Vector access test (two operations): 1034
>>> [Vector 1b] Implicit cast test (two operations): 483
>>> [Vector 2b] Explicit cast test (two operations): 624
>>> [Vector 3b] As cast test (two operations): 679
>>> 
>>> -Original Message-
>>> From: flashcoders-boun...@chattyfig.figleaf.com
>>> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
>>> Cowburn
>>> Sent: zondag 27 december 2009 14:07
>>> To: Flash Coders List
>>> Subject: Re: [Flashcoders] Performance from casting array/vector?
>>> 
>>> Hi Cor,
>>> 
>>> This was my test class, just a couple of dummy methods that do a variable
>>> declaration and an increment:
>>> 
>>> package  {   /**
>>>* Internal test class
>>>*/
>>>   public class TestClass
>>>   {
>>>   public function someMethod():void
>>>   {
>>>   var i:int = 0;
>>>   i++;
>>>   }
>>> 
>>>   public function someOtherMethod():void
>>>   {
>>>   var i:int = 0;
>>>   i++;
>>>   }
>>>   }
>>> }
>>> 
>>> 
>>> Piers
>>> 
>>> 
>>> On 27 Dec 2009, at 11:52, Cor wrote:
>>> 
>>>
 Hi piers,
 
 I am trying to follow your topic.
 What is in your TestClass.as??
 
 Kind regards
 Cor
 
 -Original Message-
 From: flashcoders-boun...@chattyfig.figleaf.com
 [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
 Cowburn
 Sent: zondag 27 december 2009 12:35
 To: Flash Coders List
 Subject: Re: [Flashcoders] Performance from casting array/vector?
 
 Hi Steve,
 
 I thought it'd be useful to have some actual figures, so I put together a
 quick test. Test code was as follows:
 
 package  {
  import flash.display.Sprite;
  import flash.utils.getTimer;
  /**
   * @author Piers Cowburn
   */
  public class ArrayAccessTest extends Sprite   {
  private const ITERATIONS:int = 100;
 
  public function ArrayAccessTest()
  {   trace("Starting tests...");
 
  var startTimer:int;
  var i:int;
  var j:int;
 
  var array:Array = [new TestClass(), new TestClass(), new
 TestClass()];
  var vector:Vector. = new Vector.();
  vector.push(new TestClass());
  vector.push(new TestClass());
  vector.push(new TestClass());
  var numItems:int = array.length;
  var implicitCast:TestClass;
  var explicitCast:TestClass;
  var asCast:TestClass;
 
  //
  // [Array 0a] Array access test
  startTimer = getTimer();
  for (i = 0; i < ITERATIONS; ++i)
  {
  for (j = 0; j 

Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Paul Andrews

Piers Cowburn wrote:

Cool, looks like the implicit cast is faster across the board, and almost twice 
as fast as just using the array access operator.
  
For an object of a known class, I think the compiler is just referring 
directly to the method rather than looking it up. When a method is 
invoked on an abstract object it has to look at the class info for the 
object to locate the method AT RUNTIME - hence the overhead. When the 
class is known it can call the method directly without a runtime lookup.


In the case  of the explicit cast, I would expect that the cast is 
pointless and adding needless overhead since the method reference is 
using the method lookup at compile time from the variable, not from the 
cast. The cast adds needless overhead at run time.


Paul


On 27 Dec 2009, at 13:13, Cor wrote:

  

With this, my results are:
Starting tests...
[Array 0a] Array access test: 462
[Array 1a] Implicit cast test: 258
[Array 2a] Explicit cast test: 406
[Array 3a] As cast test: 429
[Array 0b] Array access test (two operations): 1062
[Array 1b] Implicit cast test (two operations): 477
[Array 2b] Explicit cast test (two operations): 647
[Array 3b] As cast test (two operations): 652
[Vector 0a] Vector access test: 458
[Vector 1a] Implicit cast test: 252
[Vector 2a] Explicit cast test: 402
[Vector 3a] As cast test: 425
[Vector 0b] Vector access test (two operations): 1034
[Vector 1b] Implicit cast test (two operations): 483
[Vector 2b] Explicit cast test (two operations): 624
[Vector 3b] As cast test (two operations): 679

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
Cowburn
Sent: zondag 27 december 2009 14:07
To: Flash Coders List
Subject: Re: [Flashcoders] Performance from casting array/vector?

Hi Cor,

This was my test class, just a couple of dummy methods that do a variable
declaration and an increment:

package  
{
   /**

* Internal test class
*/
   public class TestClass
   {
   public function someMethod():void
   {
   var i:int = 0;
   i++;
   }

   public function someOtherMethod():void
   {
   var i:int = 0;
   i++;
   }
   }
}


Piers


On 27 Dec 2009, at 11:52, Cor wrote:



Hi piers,

I am trying to follow your topic.
What is in your TestClass.as??

Kind regards
Cor

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
Cowburn
Sent: zondag 27 december 2009 12:35
To: Flash Coders List
Subject: Re: [Flashcoders] Performance from casting array/vector?

Hi Steve,

I thought it'd be useful to have some actual figures, so I put together a
quick test. Test code was as follows:

package  
{

  import flash.display.Sprite;
  import flash.utils.getTimer;


  /**
   * @author Piers Cowburn
   */
  public class ArrayAccessTest extends Sprite 
  {

  private const ITERATIONS:int = 100;

  public function ArrayAccessTest()
  { 
  trace("Starting tests...");


  var startTimer:int;
  var i:int;
  var j:int;

  var array:Array = [new TestClass(), new TestClass(), new
TestClass()];
  var vector:Vector. = new Vector.();
  vector.push(new TestClass());
  vector.push(new TestClass());
  vector.push(new TestClass());
  var numItems:int = array.length;
  var implicitCast:TestClass;
  var explicitCast:TestClass;
  var asCast:TestClass;

  //
  // [Array 0a] Array access test
  startTimer = getTimer();
  for (i = 0; i < ITERATIONS; ++i)
  {
  for (j = 0; j < numItems; ++j)
  {
 array[j].someMethod();
  }
  }
  trace("[Array 0a] Array access test: " +

(getTimer()-startTimer));

  //
  // [Array 1a] Implicit cast test
  startTimer = getTimer();
  for (i = 0; i < ITERATIONS; ++i)
  {
  for (j = 0; j < numItems; ++j)
  {
  implicitCast = array[j];
 implicitCast.someMethod();
  }
  }
  trace("[Array 1a] Implicit cast test: " +

(getTimer()-startTimer));

  //
  // [Array 2a] Explicit cast test
  startTimer = getTimer();
  for (i = 0; i < ITERATIONS; ++i)
  {
  for (j = 0; j < numItems; ++j)
  {
  explicitCast = TestClass(array[j]);
 explicitCast.someMethod();
  }
  }
  trace("[Array 2a] Explicit cast test: " +

(getTimer()-startTimer));

  //
  // [Array 3a] As cast test
  startTimer = getTimer();
  for (i = 0; i < ITERATIONS; ++i)
  {
  for (j = 0; j < numItems; ++j)
  {
   

Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Piers Cowburn
Hi Henrik,

You're right, they are viable alternatives, but I didn't use either of those 
because standard for loops are faster – see this post from Jackson Dunstan: 
http://jacksondunstan.com/articles/358

I might throw them in though, for completeness, if I get some time this 
afternoon.

Piers

On 27 Dec 2009, at 13:43, Henrik Andersson wrote:

> Piers Cowburn wrote:
>> Hi Steve,
>> 
>> I thought it'd be useful to have some actual figures, so I put together a 
>> quick test. Test code was as follows:
>> 
> 
> I don't see any tests for the for .. in and for each .. in loops there. They, 
> in combination with Array, Vector, Object or Dictionary are also a possible 
> design.
> 
> I'd write the tests myself, but to put it bluntly, I am too lazy.
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Henrik Andersson

Piers Cowburn wrote:

Hi Steve,

I thought it'd be useful to have some actual figures, so I put together a quick 
test. Test code was as follows:



I don't see any tests for the for .. in and for each .. in loops there. 
They, in combination with Array, Vector, Object or Dictionary are also a 
possible design.


I'd write the tests myself, but to put it bluntly, I am too lazy.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Realaxy ActionScript Editor: XML+E4X

2009-12-27 Thread Ivan Dembicki
Hello Flashcoders,

screencast: http://www.vimeo.com/8405505

-- 
iv
http://www.bezier.ru
http://bezier.googlecode.com
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Piers Cowburn
Cool, looks like the implicit cast is faster across the board, and almost twice 
as fast as just using the array access operator.


On 27 Dec 2009, at 13:13, Cor wrote:

> With this, my results are:
> Starting tests...
> [Array 0a] Array access test: 462
> [Array 1a] Implicit cast test: 258
> [Array 2a] Explicit cast test: 406
> [Array 3a] As cast test: 429
> [Array 0b] Array access test (two operations): 1062
> [Array 1b] Implicit cast test (two operations): 477
> [Array 2b] Explicit cast test (two operations): 647
> [Array 3b] As cast test (two operations): 652
> [Vector 0a] Vector access test: 458
> [Vector 1a] Implicit cast test: 252
> [Vector 2a] Explicit cast test: 402
> [Vector 3a] As cast test: 425
> [Vector 0b] Vector access test (two operations): 1034
> [Vector 1b] Implicit cast test (two operations): 483
> [Vector 2b] Explicit cast test (two operations): 624
> [Vector 3b] As cast test (two operations): 679
> 
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
> Cowburn
> Sent: zondag 27 december 2009 14:07
> To: Flash Coders List
> Subject: Re: [Flashcoders] Performance from casting array/vector?
> 
> Hi Cor,
> 
> This was my test class, just a couple of dummy methods that do a variable
> declaration and an increment:
> 
> package  
> {
>/**
> * Internal test class
> */
>public class TestClass
>{
>public function someMethod():void
>{
>var i:int = 0;
>i++;
>}
> 
>public function someOtherMethod():void
>{
>var i:int = 0;
>i++;
>}
>}
> }
> 
> 
> Piers
> 
> 
> On 27 Dec 2009, at 11:52, Cor wrote:
> 
>> Hi piers,
>> 
>> I am trying to follow your topic.
>> What is in your TestClass.as??
>> 
>> Kind regards
>> Cor
>> 
>> -Original Message-
>> From: flashcoders-boun...@chattyfig.figleaf.com
>> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
>> Cowburn
>> Sent: zondag 27 december 2009 12:35
>> To: Flash Coders List
>> Subject: Re: [Flashcoders] Performance from casting array/vector?
>> 
>> Hi Steve,
>> 
>> I thought it'd be useful to have some actual figures, so I put together a
>> quick test. Test code was as follows:
>> 
>> package  
>> {
>>   import flash.display.Sprite;
>>   import flash.utils.getTimer;
>> 
>>   /**
>>* @author Piers Cowburn
>>*/
>>   public class ArrayAccessTest extends Sprite 
>>   {
>>   private const ITERATIONS:int = 100;
>> 
>>   public function ArrayAccessTest()
>>   { 
>>   trace("Starting tests...");
>> 
>>   var startTimer:int;
>>   var i:int;
>>   var j:int;
>> 
>>   var array:Array = [new TestClass(), new TestClass(), new
>> TestClass()];
>>   var vector:Vector. = new Vector.();
>>   vector.push(new TestClass());
>>   vector.push(new TestClass());
>>   vector.push(new TestClass());
>>   var numItems:int = array.length;
>>   var implicitCast:TestClass;
>>   var explicitCast:TestClass;
>>   var asCast:TestClass;
>> 
>>   //
>>   // [Array 0a] Array access test
>>   startTimer = getTimer();
>>   for (i = 0; i < ITERATIONS; ++i)
>>   {
>>   for (j = 0; j < numItems; ++j)
>>   {
>>  array[j].someMethod();
>>   }
>>   }
>>   trace("[Array 0a] Array access test: " +
>> (getTimer()-startTimer));
>> 
>>   //
>>   // [Array 1a] Implicit cast test
>>   startTimer = getTimer();
>>   for (i = 0; i < ITERATIONS; ++i)
>>   {
>>   for (j = 0; j < numItems; ++j)
>>   {
>>   implicitCast = array[j];
>>  implicitCast.someMethod();
>>   }
>>   }
>>   trace("[Array 1a] Implicit cast test: " +
>> (getTimer()-startTimer));
>> 
>>   //
>>   // [Array 2a] Explicit cast test
>>   startTimer = getTimer();
>>   for (i = 0; i < ITERATIONS; ++i)
>>   {
>>   for (j = 0; j < numItems; ++j)
>>   {
>>   explicitCast = TestClass(array[j]);
>>  explicitCast.someMethod();
>>   }
>>   }
>>   trace("[Array 2a] Explicit cast test: " +
>> (getTimer()-startTimer));
>> 
>>   //
>>   // [Array 3a] As cast test
>>   startTimer = getTimer();
>>   for (i = 0; i < ITERATIONS; ++i)
>>   {
>>   for (j = 0; j < numItems; ++j)
>>   {
>>   asCast = array[j] as TestClass;
>>  asCast.someMethod();
>>   }
>>   }
>>   trace("[Array 3a] As cast test: " + (getTimer()-startTimer));
>> 
>>   //
>>   // [

RE: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Cor
With this, my results are:
Starting tests...
[Array 0a] Array access test: 462
[Array 1a] Implicit cast test: 258
[Array 2a] Explicit cast test: 406
[Array 3a] As cast test: 429
[Array 0b] Array access test (two operations): 1062
[Array 1b] Implicit cast test (two operations): 477
[Array 2b] Explicit cast test (two operations): 647
[Array 3b] As cast test (two operations): 652
[Vector 0a] Vector access test: 458
[Vector 1a] Implicit cast test: 252
[Vector 2a] Explicit cast test: 402
[Vector 3a] As cast test: 425
[Vector 0b] Vector access test (two operations): 1034
[Vector 1b] Implicit cast test (two operations): 483
[Vector 2b] Explicit cast test (two operations): 624
[Vector 3b] As cast test (two operations): 679

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
Cowburn
Sent: zondag 27 december 2009 14:07
To: Flash Coders List
Subject: Re: [Flashcoders] Performance from casting array/vector?

Hi Cor,

This was my test class, just a couple of dummy methods that do a variable
declaration and an increment:

package  
{
/**
 * Internal test class
 */
public class TestClass
{
public function someMethod():void
{
var i:int = 0;
i++;
}

public function someOtherMethod():void
{
var i:int = 0;
i++;
}
}
}


Piers


On 27 Dec 2009, at 11:52, Cor wrote:

> Hi piers,
> 
> I am trying to follow your topic.
> What is in your TestClass.as??
> 
> Kind regards
> Cor
> 
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
> Cowburn
> Sent: zondag 27 december 2009 12:35
> To: Flash Coders List
> Subject: Re: [Flashcoders] Performance from casting array/vector?
> 
> Hi Steve,
> 
> I thought it'd be useful to have some actual figures, so I put together a
> quick test. Test code was as follows:
> 
> package  
> {
>import flash.display.Sprite;
>import flash.utils.getTimer;
> 
>/**
> * @author Piers Cowburn
> */
>public class ArrayAccessTest extends Sprite 
>{
>private const ITERATIONS:int = 100;
> 
>public function ArrayAccessTest()
>{ 
>trace("Starting tests...");
> 
>var startTimer:int;
>var i:int;
>var j:int;
> 
>var array:Array = [new TestClass(), new TestClass(), new
> TestClass()];
>var vector:Vector. = new Vector.();
>vector.push(new TestClass());
>vector.push(new TestClass());
>vector.push(new TestClass());
>var numItems:int = array.length;
>var implicitCast:TestClass;
>var explicitCast:TestClass;
>var asCast:TestClass;
> 
>//
>// [Array 0a] Array access test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>   array[j].someMethod();
>}
>}
>trace("[Array 0a] Array access test: " +
> (getTimer()-startTimer));
> 
>//
>// [Array 1a] Implicit cast test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>implicitCast = array[j];
>   implicitCast.someMethod();
>}
>}
>trace("[Array 1a] Implicit cast test: " +
> (getTimer()-startTimer));
> 
>//
>// [Array 2a] Explicit cast test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>explicitCast = TestClass(array[j]);
>   explicitCast.someMethod();
>}
>}
>trace("[Array 2a] Explicit cast test: " +
> (getTimer()-startTimer));
> 
>//
>// [Array 3a] As cast test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>asCast = array[j] as TestClass;
>   asCast.someMethod();
>}
>}
>trace("[Array 3a] As cast test: " + (getTimer()-startTimer));
> 
>//
>// [Array 0b] Array access test (two operations)
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>   array[j].someMethod();
>   array[j].someOther

RE: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Cor
Hi Piers,

Thanks,

I will try this too.

Kind regards
Cor

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
Cowburn
Sent: zondag 27 december 2009 14:07
To: Flash Coders List
Subject: Re: [Flashcoders] Performance from casting array/vector?

Hi Cor,

This was my test class, just a couple of dummy methods that do a variable
declaration and an increment:

package  
{
/**
 * Internal test class
 */
public class TestClass
{
public function someMethod():void
{
var i:int = 0;
i++;
}

public function someOtherMethod():void
{
var i:int = 0;
i++;
}
}
}


Piers


On 27 Dec 2009, at 11:52, Cor wrote:

> Hi piers,
> 
> I am trying to follow your topic.
> What is in your TestClass.as??
> 
> Kind regards
> Cor
> 
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
> Cowburn
> Sent: zondag 27 december 2009 12:35
> To: Flash Coders List
> Subject: Re: [Flashcoders] Performance from casting array/vector?
> 
> Hi Steve,
> 
> I thought it'd be useful to have some actual figures, so I put together a
> quick test. Test code was as follows:
> 
> package  
> {
>import flash.display.Sprite;
>import flash.utils.getTimer;
> 
>/**
> * @author Piers Cowburn
> */
>public class ArrayAccessTest extends Sprite 
>{
>private const ITERATIONS:int = 100;
> 
>public function ArrayAccessTest()
>{ 
>trace("Starting tests...");
> 
>var startTimer:int;
>var i:int;
>var j:int;
> 
>var array:Array = [new TestClass(), new TestClass(), new
> TestClass()];
>var vector:Vector. = new Vector.();
>vector.push(new TestClass());
>vector.push(new TestClass());
>vector.push(new TestClass());
>var numItems:int = array.length;
>var implicitCast:TestClass;
>var explicitCast:TestClass;
>var asCast:TestClass;
> 
>//
>// [Array 0a] Array access test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>   array[j].someMethod();
>}
>}
>trace("[Array 0a] Array access test: " +
> (getTimer()-startTimer));
> 
>//
>// [Array 1a] Implicit cast test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>implicitCast = array[j];
>   implicitCast.someMethod();
>}
>}
>trace("[Array 1a] Implicit cast test: " +
> (getTimer()-startTimer));
> 
>//
>// [Array 2a] Explicit cast test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>explicitCast = TestClass(array[j]);
>   explicitCast.someMethod();
>}
>}
>trace("[Array 2a] Explicit cast test: " +
> (getTimer()-startTimer));
> 
>//
>// [Array 3a] As cast test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>asCast = array[j] as TestClass;
>   asCast.someMethod();
>}
>}
>trace("[Array 3a] As cast test: " + (getTimer()-startTimer));
> 
>//
>// [Array 0b] Array access test (two operations)
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>   array[j].someMethod();
>   array[j].someOtherMethod();
>}
>}
>trace("[Array 0b] Array access test (two operations): " +
> (getTimer()-startTimer));
> 
>//
>// [Array 1b] Implicit cast test (two operations)
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>implicitCast = array[j];
>   implicitCast.someMethod();
>   implicitCast.someOtherMethod();
>}
>}
>trace("[Array 1b] Implicit cast test (two operation

Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Piers Cowburn
Hi Cor,

This was my test class, just a couple of dummy methods that do a variable 
declaration and an increment:

package  
{
/**
 * Internal test class
 */
public class TestClass
{
public function someMethod():void
{
var i:int = 0;
i++;
}

public function someOtherMethod():void
{
var i:int = 0;
i++;
}
}
}


Piers


On 27 Dec 2009, at 11:52, Cor wrote:

> Hi piers,
> 
> I am trying to follow your topic.
> What is in your TestClass.as??
> 
> Kind regards
> Cor
> 
> -Original Message-
> From: flashcoders-boun...@chattyfig.figleaf.com
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
> Cowburn
> Sent: zondag 27 december 2009 12:35
> To: Flash Coders List
> Subject: Re: [Flashcoders] Performance from casting array/vector?
> 
> Hi Steve,
> 
> I thought it'd be useful to have some actual figures, so I put together a
> quick test. Test code was as follows:
> 
> package  
> {
>import flash.display.Sprite;
>import flash.utils.getTimer;
> 
>/**
> * @author Piers Cowburn
> */
>public class ArrayAccessTest extends Sprite 
>{
>private const ITERATIONS:int = 100;
> 
>public function ArrayAccessTest()
>{ 
>trace("Starting tests...");
> 
>var startTimer:int;
>var i:int;
>var j:int;
> 
>var array:Array = [new TestClass(), new TestClass(), new
> TestClass()];
>var vector:Vector. = new Vector.();
>vector.push(new TestClass());
>vector.push(new TestClass());
>vector.push(new TestClass());
>var numItems:int = array.length;
>var implicitCast:TestClass;
>var explicitCast:TestClass;
>var asCast:TestClass;
> 
>//
>// [Array 0a] Array access test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>   array[j].someMethod();
>}
>}
>trace("[Array 0a] Array access test: " +
> (getTimer()-startTimer));
> 
>//
>// [Array 1a] Implicit cast test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>implicitCast = array[j];
>   implicitCast.someMethod();
>}
>}
>trace("[Array 1a] Implicit cast test: " +
> (getTimer()-startTimer));
> 
>//
>// [Array 2a] Explicit cast test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>explicitCast = TestClass(array[j]);
>   explicitCast.someMethod();
>}
>}
>trace("[Array 2a] Explicit cast test: " +
> (getTimer()-startTimer));
> 
>//
>// [Array 3a] As cast test
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>asCast = array[j] as TestClass;
>   asCast.someMethod();
>}
>}
>trace("[Array 3a] As cast test: " + (getTimer()-startTimer));
> 
>//
>// [Array 0b] Array access test (two operations)
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>   array[j].someMethod();
>   array[j].someOtherMethod();
>}
>}
>trace("[Array 0b] Array access test (two operations): " +
> (getTimer()-startTimer));
> 
>//
>// [Array 1b] Implicit cast test (two operations)
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>implicitCast = array[j];
>   implicitCast.someMethod();
>   implicitCast.someOtherMethod();
>}
>}
>trace("[Array 1b] Implicit cast test (two operations): " +
> (getTimer()-startTimer));
> 
>//
>// [Array 2b] Explicit cast test (two operations)
>startTimer = getTimer();
>for (i = 0; i < ITERATIONS; ++i)
>{
>for (j = 0; j < numItems; ++j)
>{
>explicitCast = TestClass(array[j

RE: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Cor
My results were:
Starting tests...
[Array 0a] Array access test: 446
[Array 1a] Implicit cast test: 236
[Array 2a] Explicit cast test: 402
[Array 3a] As cast test: 440
[Array 0b] Array access test (two operations): 973
[Array 1b] Implicit cast test (two operations): 430
[Array 2b] Explicit cast test (two operations): 600
[Array 3b] As cast test (two operations): 627
[Vector 0a] Vector access test: 446
[Vector 1a] Implicit cast test: 243
[Vector 2a] Explicit cast test: 400
[Vector 3a] As cast test: 421
[Vector 0b] Vector access test (two operations): 989
[Vector 1b] Implicit cast test (two operations): 423
[Vector 2b] Explicit cast test (two operations): 588
[Vector 3b] As cast test (two operations): 643

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
Cowburn
Sent: zondag 27 december 2009 12:35
To: Flash Coders List
Subject: Re: [Flashcoders] Performance from casting array/vector?

Hi Steve,

I thought it'd be useful to have some actual figures, so I put together a
quick test. Test code was as follows:

package  
{
import flash.display.Sprite;
import flash.utils.getTimer;

/**
 * @author Piers Cowburn
 */
public class ArrayAccessTest extends Sprite 
{
private const ITERATIONS:int = 100;

public function ArrayAccessTest()
{ 
trace("Starting tests...");

var startTimer:int;
var i:int;
var j:int;

var array:Array = [new TestClass(), new TestClass(), new
TestClass()];
var vector:Vector. = new Vector.();
vector.push(new TestClass());
vector.push(new TestClass());
vector.push(new TestClass());
var numItems:int = array.length;
var implicitCast:TestClass;
var explicitCast:TestClass;
var asCast:TestClass;

//
// [Array 0a] Array access test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
   array[j].someMethod();
}
}
trace("[Array 0a] Array access test: " +
(getTimer()-startTimer));

//
// [Array 1a] Implicit cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
implicitCast = array[j];
   implicitCast.someMethod();
}
}
trace("[Array 1a] Implicit cast test: " +
(getTimer()-startTimer));

//
// [Array 2a] Explicit cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
explicitCast = TestClass(array[j]);
   explicitCast.someMethod();
}
}
trace("[Array 2a] Explicit cast test: " +
(getTimer()-startTimer));

//
// [Array 3a] As cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
asCast = array[j] as TestClass;
   asCast.someMethod();
}
}
trace("[Array 3a] As cast test: " + (getTimer()-startTimer));

//
// [Array 0b] Array access test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
   array[j].someMethod();
   array[j].someOtherMethod();
}
}
trace("[Array 0b] Array access test (two operations): " +
(getTimer()-startTimer));

//
// [Array 1b] Implicit cast test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
implicitCast = array[j];
   implicitCast.someMethod();
   implicitCast.someOtherMethod();
}
}
trace("[Array 1b] Implicit cast test (two operations): " +
(getTimer()-startTimer));

//
// [Array 2b] Explicit cast test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
   

RE: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Cor
Never mind, i did this:
/**
 * @class   : TestClass
 * 
 * @author  : Cor van Dooren
 * @version : 1.0
 *
 * @usage   : 
 *
 */
package  {

import flash.display.MovieClip;
import flash.events.*;


public class TestClass extends MovieClip{

// C O N S T R U C T O R

public function TestClass() {
addEventListener(Event.ADDED_TO_STAGE, init);
}//end CONSTRUCTOR

// init
-
private function init(e:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, init);

}//end init

public function someMethod():void {
//nothing
}

public function someOtherMethod():void {
//nothing
}

}//end class
}//end package

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
Cowburn
Sent: zondag 27 december 2009 12:35
To: Flash Coders List
Subject: Re: [Flashcoders] Performance from casting array/vector?

Hi Steve,

I thought it'd be useful to have some actual figures, so I put together a
quick test. Test code was as follows:

package  
{
import flash.display.Sprite;
import flash.utils.getTimer;

/**
 * @author Piers Cowburn
 */
public class ArrayAccessTest extends Sprite 
{
private const ITERATIONS:int = 100;

public function ArrayAccessTest()
{ 
trace("Starting tests...");

var startTimer:int;
var i:int;
var j:int;

var array:Array = [new TestClass(), new TestClass(), new
TestClass()];
var vector:Vector. = new Vector.();
vector.push(new TestClass());
vector.push(new TestClass());
vector.push(new TestClass());
var numItems:int = array.length;
var implicitCast:TestClass;
var explicitCast:TestClass;
var asCast:TestClass;

//
// [Array 0a] Array access test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
   array[j].someMethod();
}
}
trace("[Array 0a] Array access test: " +
(getTimer()-startTimer));

//
// [Array 1a] Implicit cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
implicitCast = array[j];
   implicitCast.someMethod();
}
}
trace("[Array 1a] Implicit cast test: " +
(getTimer()-startTimer));

//
// [Array 2a] Explicit cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
explicitCast = TestClass(array[j]);
   explicitCast.someMethod();
}
}
trace("[Array 2a] Explicit cast test: " +
(getTimer()-startTimer));

//
// [Array 3a] As cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
asCast = array[j] as TestClass;
   asCast.someMethod();
}
}
trace("[Array 3a] As cast test: " + (getTimer()-startTimer));

//
// [Array 0b] Array access test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
   array[j].someMethod();
   array[j].someOtherMethod();
}
}
trace("[Array 0b] Array access test (two operations): " +
(getTimer()-startTimer));

//
// [Array 1b] Implicit cast test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
implicitCast = array[j];

RE: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Cor
Hi piers,

I am trying to follow your topic.
What is in your TestClass.as??

Kind regards
Cor

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Piers
Cowburn
Sent: zondag 27 december 2009 12:35
To: Flash Coders List
Subject: Re: [Flashcoders] Performance from casting array/vector?

Hi Steve,

I thought it'd be useful to have some actual figures, so I put together a
quick test. Test code was as follows:

package  
{
import flash.display.Sprite;
import flash.utils.getTimer;

/**
 * @author Piers Cowburn
 */
public class ArrayAccessTest extends Sprite 
{
private const ITERATIONS:int = 100;

public function ArrayAccessTest()
{ 
trace("Starting tests...");

var startTimer:int;
var i:int;
var j:int;

var array:Array = [new TestClass(), new TestClass(), new
TestClass()];
var vector:Vector. = new Vector.();
vector.push(new TestClass());
vector.push(new TestClass());
vector.push(new TestClass());
var numItems:int = array.length;
var implicitCast:TestClass;
var explicitCast:TestClass;
var asCast:TestClass;

//
// [Array 0a] Array access test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
   array[j].someMethod();
}
}
trace("[Array 0a] Array access test: " +
(getTimer()-startTimer));

//
// [Array 1a] Implicit cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
implicitCast = array[j];
   implicitCast.someMethod();
}
}
trace("[Array 1a] Implicit cast test: " +
(getTimer()-startTimer));

//
// [Array 2a] Explicit cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
explicitCast = TestClass(array[j]);
   explicitCast.someMethod();
}
}
trace("[Array 2a] Explicit cast test: " +
(getTimer()-startTimer));

//
// [Array 3a] As cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
asCast = array[j] as TestClass;
   asCast.someMethod();
}
}
trace("[Array 3a] As cast test: " + (getTimer()-startTimer));

//
// [Array 0b] Array access test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
   array[j].someMethod();
   array[j].someOtherMethod();
}
}
trace("[Array 0b] Array access test (two operations): " +
(getTimer()-startTimer));

//
// [Array 1b] Implicit cast test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
implicitCast = array[j];
   implicitCast.someMethod();
   implicitCast.someOtherMethod();
}
}
trace("[Array 1b] Implicit cast test (two operations): " +
(getTimer()-startTimer));

//
// [Array 2b] Explicit cast test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
explicitCast = TestClass(array[j]);
   explicitCast.someMethod();
   explicitCast.someOtherMethod();
}
}
trace("[Array 2b] Explicit cast test (two operations): " +
(getTimer()-startTimer));

//
// [Array 3b] As cast test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
asCast = array[j] as TestClass;
 

Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Piers Cowburn
Hi Steve,

I thought it'd be useful to have some actual figures, so I put together a quick 
test. Test code was as follows:

package  
{
import flash.display.Sprite;
import flash.utils.getTimer;

/**
 * @author Piers Cowburn
 */
public class ArrayAccessTest extends Sprite 
{
private const ITERATIONS:int = 100;

public function ArrayAccessTest()
{ 
trace("Starting tests...");

var startTimer:int;
var i:int;
var j:int;

var array:Array = [new TestClass(), new TestClass(), new 
TestClass()];
var vector:Vector. = new Vector.();
vector.push(new TestClass());
vector.push(new TestClass());
vector.push(new TestClass());
var numItems:int = array.length;
var implicitCast:TestClass;
var explicitCast:TestClass;
var asCast:TestClass;

//
// [Array 0a] Array access test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
   array[j].someMethod();
}
}
trace("[Array 0a] Array access test: " + (getTimer()-startTimer));

//
// [Array 1a] Implicit cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
implicitCast = array[j];
   implicitCast.someMethod();
}
}
trace("[Array 1a] Implicit cast test: " + (getTimer()-startTimer));

//
// [Array 2a] Explicit cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
explicitCast = TestClass(array[j]);
   explicitCast.someMethod();
}
}
trace("[Array 2a] Explicit cast test: " + (getTimer()-startTimer));

//
// [Array 3a] As cast test
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
asCast = array[j] as TestClass;
   asCast.someMethod();
}
}
trace("[Array 3a] As cast test: " + (getTimer()-startTimer));

//
// [Array 0b] Array access test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
   array[j].someMethod();
   array[j].someOtherMethod();
}
}
trace("[Array 0b] Array access test (two operations): " + 
(getTimer()-startTimer));

//
// [Array 1b] Implicit cast test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
implicitCast = array[j];
   implicitCast.someMethod();
   implicitCast.someOtherMethod();
}
}
trace("[Array 1b] Implicit cast test (two operations): " + 
(getTimer()-startTimer));

//
// [Array 2b] Explicit cast test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
explicitCast = TestClass(array[j]);
   explicitCast.someMethod();
   explicitCast.someOtherMethod();
}
}
trace("[Array 2b] Explicit cast test (two operations): " + 
(getTimer()-startTimer));

//
// [Array 3b] As cast test (two operations)
startTimer = getTimer();
for (i = 0; i < ITERATIONS; ++i)
{
for (j = 0; j < numItems; ++j)
{
asCast = array[j] as TestClass;
   asCast.someMethod();
   asCast.someOtherMethod();
}
}
trace("[Array 3b] As cast test (two operations): " + 
(getTimer()-startTimer));



//
// [Vector 0a] Vector access test
startTimer = getTimer();
for (i = 0; i < ITERATI

Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Henrik Andersson

Fumio Nonaka wrote:

A variable declaration is processed before statements.  Therefore, it
does not matter if it is inside or outside a loop.



Except for your case where it has an assignment.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Performance from casting array/vector?

2009-12-27 Thread Piers Cowburn
あぁ、もちろんです!ありがとう。

On 27 Dec 2009, at 06:02, Fumio Nonaka wrote:

> A variable declaration is processed before statements.  Therefore, it does 
> not matter if it is inside or outside a loop.
> 
> myClass = new MyClass();
> trace(myClass);  // Output: [object MyClass]
> while (false) {
>   var myClass:MyClass;
> }
> _
> Piers Cowburn wrote:
>> AFAIK, using implicit casting rather than explicit in this case is faster, 
>> so A1 in your examples is faster than A2. Also, it's better to move your 
>> variable declaration outside the loop:
>> var i:int = myArray.length;
>> // Variable is declared once here and then reused
>> var myClass:MyClass;
>> while (i--)
>> {
>>   myClass = myArray[i];
>> }
> 
> Good luck,
> -- 
> Fumio Nonaka
> http://www.FumioNonaka.com/
> My books
> Flash community
> English blog
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders