Created
October 8, 2012 11:57
-
-
Save Dovyski/3852132 to your computer and use it in GitHub Desktop.
FlxGroup.sort() performance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've just added 1000 FlxSprite's to a FlxGroup and called sort() 1000 times. | |
I ran the test 6 times for each approach. All times are in milliseconds. | |
Approach #1 (no fix, FlxGroup crashes if the sorting property is missing): | |
debug: | |
4538 | |
4650 | |
4962 | |
4217 | |
5048 | |
4654 | |
release: | |
2656 | |
2875 | |
3093 | |
2782 | |
3032 | |
2829 | |
Approach #2: fix using hasOwnProperty(): | |
debug: | |
9251 | |
9621 | |
10020 | |
9461 | |
9303 | |
9099 | |
release: | |
5844 | |
5735 | |
5500 | |
5765 | |
5500 | |
5453 | |
Approach #3: fix using (prop in obj) | |
debug: | |
6421 | |
6634 | |
6240 | |
6748 | |
6839 | |
6547 | |
release: | |
4078 | |
3767 | |
3563 | |
3798 | |
3734 | |
4031 | |
-------------------------------------------------- | |
IMPLEMENTATION | |
------------------------------------------------ | |
Approach #3 (fix using prop in obj) was implemented. Below are the results of the same test running with the implemented code. The test was run with 4 instead of 6 iterations. | |
debug: | |
6211 | |
6203 | |
6083 | |
6243 | |
release: | |
3584 | |
3613 | |
3568 | |
3637 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment