AS3 framework option #3
After analyzing 2 most popular framework both from syntax and performance point of view – I realized that both frameworks is not good enough for me. I work mainly with games and heavy applications that requires both code writing speed and code execution speed. With that knowledge I did what any programmer usually does in such situation – started my own project! where everything will be perfect! it will be fast! it will be comfortable to work with! and sun will shine all day long!
So I started with writing requirements…
AS3 framework requirements
Primary goal : framework must run fast! (and by fast I mean fastest possible…)
Secondary goal : framework must be simple! (and by that I mean dead simple…)
ah yes.. and it have to actually implement MVC architecture too…
MVC is very simple. There is only 2 main things it actually does:
- it lets you brake you application in parts and get those parts easily.
- it lets those parts to communicate.
and it does it in a way that almost completely removes hassle of creating architecture for your big and complicated application and leave you with fun part. It standardize your code for team work and for reuse.
Framework will implement MVC in this way:
|set up your application||run Commands||Get models||Get mediators||Send messages||Listen for messages|
So what I did was – I took the parts from PureMVC and RobotLegs that I loved… I discarded everything that I didn’t liked:
- Kept RobotLegs like dependency injection.
- Used PureMVC notification system like messaging without ANY need to convert any types.
- Avoid any of bad practices that are technically possible in PureMVC(getting mediators) and in RobotLegs(listen events from model).
- Kept API dead simple and intuitive.
- Kept modular programming dead simple.
In the end I come up with this solution – project code-name PureLegs !!
You can find it in GitHub : PureLegs-framework
I would ask you to have a look at it! I need you help, try to use it! tell me what you would like to see better… and most of all – what you don’t like about it.
PureMVC is faster then RobotLegs in almost all cases, and PureLegs is faster then PureMVC in almost all cases! (and the single case there it is not – it’s equal)
Table with data for actions per 1ms.
|RobetLegs runs/1ms||PureMVC runs/1ms||PureLegs runs/1ms|
|Time to run 1 command:|
|Command with nothing:||144.9||513.3||1385.0|
|Command with parameter:||100.4||511.0||1344.1|
|Command with Model:||94.2||480.3||889.7|
|Command with Model and View call:||77.0||258.3||545.3|
|Time to register 1 mediator:|
|>> max 1000 mediators:||21.3||50.0||47.6|
|>>> max 2000 mediators:||21.5||48.8||51.3|
|>>> max 5000 mediators:||22.7||49.0||49.0|
|Time to remove 1 mediator:|
|>>> max 1000 mediators:||90.9||17.9||83.3|
|>>> max 2000 mediators:||50.0||10.2||62.5|
|>>> max 5000 mediators:||27.8||4.4||29.9|
|Communication with many mediators:|
|Message to 1 receiving mediators:||994.0||1902.9||3096.0|
|Message to 100 receiving mediators:||33.6||16.4||206.6|
|>>> time for 1 communication:||3364.7||1636.4||20661.2|
|Message to 200 receiving mediators:||16.8||8.3||100.8|
|>>> time for 1 communication:||3364.7||1653.4||20161.3|
|Message to 500 receiving mediators:||6.7||3.4||40.9|
|>>> time for 1 communication:||3349.0||1676.3||20470.8|
|Message to 1000 receiving mediators:||3.4||1.7||21.2|
|>>> time for 1 communication:||3414.1||1692.2||21216.4|
Another table with how PureLegs many times is faster:
|Sending messages to 1 listener||1.63||3.11|
|Sending messages to many listeners||12.19||6.14|