What is the fastest way to get an object constructor in AS3?

Which of these 3 is the fastest (least CPU cycles) on AVM2 in ActionScript 3?

  • Object(instance).constructor
  • (instance as Object).constructor
  • instance["constructor"]

I would do some tests, but I don’t know how to accurately profile such things.

+3
source share
1 answer
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
performancetests.Constructors (5 iterations, 5,000,000 loops through each)                            
Player version: MAC 10,0,32,18 (debug)
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
method...................................................ttl ms...avg ms
instanceAsObjectConstructor                                9516  1903.20
instanceBracketConstructor                                 6941  1388.20
objectDotConstructor                                       9916  1983.20
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

I used the Grant Skinner AS3 Performance test harness and got these results.

+6
source

Source: https://habr.com/ru/post/1719145/


All Articles