- 浏览: 1049186 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (538)
- 奇文共赏 (36)
- spring (13)
- hibernate (10)
- AOP/Aspectj (9)
- spring security (7)
- lucence (5)
- compass (3)
- jbmp (2)
- jboss rule(drools) (0)
- birt (1)
- jasper (1)
- cxf (3)
- flex (98)
- webgis (6)
- 设计模式 (1)
- 代码重构 (2)
- log4j (1)
- tomcat (9)
- 神品音乐 (1)
- 工作计划 (2)
- appfuse (1)
- svn (4)
- 寻章摘句 (3)
- eclipse (10)
- arcgis api for flex (1)
- 算法 (5)
- opengis-cs (1)
- bug心得 (13)
- 图标 (1)
- software&key (14)
- java (17)
- 搞笑视频 (13)
- sqlserver (9)
- postgresql (1)
- postgis (0)
- geoserver (5)
- 日子 (50)
- 水晶报表 (1)
- 绝对电影 (3)
- Alternativa3D (1)
- 酷站大全 (10)
- c++ (5)
- oracle (17)
- oracle spatial (25)
- flashbuilder4 (3)
- TweenLite (1)
- DailyBuild (6)
- 华山论贱 (5)
- 系统性能 (5)
- 经典古文 (6)
- SOA/SCA/OSGI (6)
- jira (2)
- Hadoop生态圈(hadoop/hbase/pig/hive/zookeeper) (37)
- 风水 (1)
- linux操作基础 (17)
- 经济 (4)
- 茶 (3)
- JUnit (1)
- C# dotNet (1)
- netbeans (1)
- Java2D (1)
- QT4 (1)
- google Test/Mock/AutoTest (3)
- maven (1)
- 3d/OSG (1)
- Eclipse RCP (3)
- CUDA (1)
- Access control (0)
- http://linux.chinaunix.net/techdoc/beginner/2008/01/29/977725.shtml (1)
- redis (1)
最新评论
-
dove19900520:
朋友,你确定你的标题跟文章内容对应???
tomcat控制浏览器不缓存 -
wussrc:
我只想说牛逼,就我接触过的那点云计算的东西,仔细想想还真是这么 ...
别样解释云计算,太TM天才跨界了 -
hw_imxy:
endpoint="/Hello/messagebr ...
flex+java代码分两个工程 -
gaohejie:
rsrsdgrfdh坎坎坷坷
Flex 与 Spring 集成 -
李涤尘:
谢谢。不过说得有点太罗嗦了。
Oracle数据库数据的导入及导出(转)
51 ActionScript 3.0 and Flex optimization techniques and practices
http://www.insideria.com/2009/04/51-actionscript-30-and-flex-op.html
A homework assignment I was recently given for a Java programming class involved a competition to see who could create the most optimized implementation of an interface which was provided by the instructor. It was a challenging and very fun assignment that I think the whole class enjoyed. I didn’t win the competition but still came out a winner because of my heightened interest in application optimization and performance tuning that I gained.
I’m personally a pretty big fan of coding standards and have been ribbed by many developers over some of the longer method, variable and class names that I sometimes choose. I've always leaned toward the side of programming that employs standards and frameworks . Rather than spending a ton of time digging around in compiler specs and messing with GC (Garbage Collection) for reasons of performance, tuning and optimization. I was leaving this to the seasoned programmers creating the standards and frameworks I use.
This isn’t to say I’ve never paid attention to performance and I enjoy building slow applications. It’s almost like two different worlds; the optimization world and the standards world. They don’t always agree with each other. There can sometimes be a trade off for performance over readability and organization or vice-versa. This article is meant to stand next to the Flex Best Practices articles that I authored.
While creating my concrete implementation for the homework assignment I discovered a powerful profiling engine in NetBeans. The NetBeans profiling engine helped me understand some of the memory usage and consumption of each property, method call and object instantiation in my program. This profiler in NetBeans is very similar to the one found in Flex Builder. Both are very powerful and very useful. I've been exploring the Flex Profiler in greater detail lately as well and using it to eradicate memory leaks for a real world application I’ve been refactoring to best practices lately.
The Java optimization homework has increased my interest in optimization and profiling for ActionScript 3.0 and Flex development. I've been piecing together ActionScript optimization techniques and practices from around the web for a couple years now. Some of these techniques are in opposition to what the standards dictate but most of software development is this way. You have to learn when to use some techniques and when to leave some out.
Here are 51 ActionScript 3.0 and Flex optimization techniques and practices. I’ve scoured the web for and filtered practices and techniques that can be adopted into your application development process. Use these in conjunction with the Flex Profiler to monitor and optimize and tune the performance of your ActionScript 3.0 and Flex RIAs.
1. Avoid the new operator when creating Arrays
var a = [];
NOT:
var a = new Array();
2. Arrays are expensive to create, do so conservatively
var vanityCollection01 : Array = new Array();
var vanityCollection02 : Array = new Array();
var vanityCollection03 : Array = new Array();
var vanityCollection04 : Array = new Array();
3. Fastest way to copy an array:
var copy : Array = sourceArray.concat();
4. Setting values in Arrays is slow
employees.push( employee );
employees[2] = employee;
5. Getting values from Arrays is twice as fast as setting
var employee : Employee = employees[2];
6. Anonymous objects are faster to create with {} vs. new
var o : * = { firstName : "John", lastName : "Smith", age : 45 };
NOT:
var p : Person = new Person();
p.firstName = "John";
p.lastName = "Smith";
p.age = 45;
7. Use static for properties methods that do not require an object instance
StringUtils.trim( "text with space at end " );
Class definition:
package
{
public final class StringUtils
{
public static function trim( s : String ) : String
{
var trimmed : String;
// implementation...
return trimmed;
}
}
}
8. Use const for properties that will never change throughout the lifecycle of the application
public const APPLICATION_PUBLISHER : String = "Kannopy, Inc.";
9. Use final when no subclasses need to be created of a class
public final class StringUtils
10. Use package level variables and functions for generalized functionality which does not require a class or instance of a class
createSnapShot( arg );
NOT:
someObjectInstance.createSnapShot( arg );
NOT:
SomeClass.createSnapShot( arg );
Class definition:
package
{
// imports…;
public function createSnapShot(target:IBitmapDrawable) : Bitmap
{
// implementation…
}
}
11. JIT won’t compile code within constructors (keep them lightweight)
package com.seantheflexguy.as3optimization
{
public class MinimalConstructor
{
public function MinimalConstructor()
{
init();
}
}
}
12. Length of method/variable names doesn't matter in ActionScript 3.0 (true in other langs)
someCrazyLongMethodNameDoesntReallyImpactPerformanceTooMuch();
13. One line assignments DO NOT buy any performance! It's a Myth! (true in other langs)
var i=0; j=10; k=200;
14. No difference in memory usage between an if statement and a switch statement
if ( condition )
{
// handle condition
}
IDENTICAL MEMORY USAGE:
switch ( condition )
{
case "A":
// logic to handle case A
break;
case "B":
// logic to handle case B
break;
}
15. Rank your if statements in order of comparisons most likely to be true
if ( conditionThatHappensAlot )
{
// logic to handle frequently met condition
}
else if ( conditionThatHappensSomtimes )
{
// handle the case that happens occaisonally
}
else
{
// handle the case that doesn’t happen that often
}
16. AVM promotes int to Number during calculations inside loops
17. Resolve issues of promotion, unknown, or incorrect object types
18. Use uint sparingly, it can be slow
var footerHex : uint = 0x00ccff;
19. Use integers for iterations
(var i: int = 0; i < n; i++) NOT for (var i: Number = 0; i < n; i++)
20. Cast to int for calculations inside loops (AVM automatically promotes int to Number)
for (;i<n2;i++) Vector3D(array[int(i*2)]).x = 2;
NOT:
for (;i<n2;i++) Vector3D(array[i*2]).x = 2;
21. Don't use int with decimals
var decimal : Number = 14.654;
NOT:
var decimal : int = 14.654;
22. Multiply vs. Divide: instead of 5000/1000 use: 5000*0.001
23. Calculate things like floor and round yourself vs. calling Math library
package com.seantheflexguy.math
{
public final class MathUtil
{
public static function round( number : Number ) : Number
{
// custom rounding implementation
}
}
}
24. Locally store function values in for and while statements instead of repeatedly accessing them
for (..){a*180/Math.PI;}
declare: toRadians = a*180/Math.PI; outside of the loop
25. Avoid calculations and method calls in loops
for (var i=0;i< myArray.lengh;i++){ }
NOT:
var len : int = myArray.lengh;
for (var i=0;i<len;i++){}
26. Remove event listeners when finished using them
removeEventListener( Event.COMPLETE, onComplete );
27. Use delete to free memory
delete someObject;
28. Use RegEx for validation, use string methods for searching
// postal code validation example using regular expressions
private var regEx:RegExp = /^[A-Z][0-9][A-Z] [0-9][A-Z][0-9]$/i;
private function validatePostal( event : Event ) : void
{
if( regEx.test( zipTextInput.text ) )
{
// handle invalid input case
}
}
// search a string using String methods
var string : String = "Search me";
var searchIndex : int = string.indexOf( "me" );
var search : String = string.substring( searchIndex, searchIndex + 2 );
29. Reuse objects to maintain a “memory plateau” DisplayObjects, URLLoader objects
30. Follow the Flex component model:
createChildren();
commitProperties();
updateDisplayList();
31. Only use Datagrids as a last resort (make sure you can’t implement in a regular List first)
32. Avoid Repeaters for scrollable data
33. Avoid the setStyle() method (One of the most expensive calls in the Flex framework)
34. Using too many containers dramatically reduces the performance of your application
<mx:Panel>
<mx:VBox>
<mx:HBox>
<mx:Label text="Label 1" />
<mx:VBox>
<mx:Label text="Label 2" />
</mx:VBox>
<mx:HBox>
<mx:Label text="Label 3" />
<mx:VBox>
<mx:Label text="Label 4" />
</mx:VBox>
</mx:HBox>
</mx:HBox>
</mx:VBox>
</mx:Panel>
35. You do not need to always use a container tag as the top-level tag of components Totally valid component, no top level container needed:
<mx:Image xmlns:mx="http://www.adobe.com/2006/mxml"
source="avatar.jpg" width="200" height="200" />
36. Remove unnecessary container wrappers to reduce container nesting
37. Avoid: The VBox container inside an tag, (eliminates redundancy)
<mx:Panel>
<mx:Label text="Label 1" />
<mx:Label text="Label 2" />
</mx:Panel>
NOT:
<mx:Panel>
<mx:VBox>
<mx:Label text="Label 1" />
<mx:Label text="Label 2" />
</mx:VBox>
</mx:Panel>
38. Avoid: VBox container inside an tag, (eliminates redundancy)
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=http://www.adobe.com/2006/mxml>
<mx:Label text="Label 1" />
<mx:Label text="Label 2" />
</mx:Application>
NOT:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=http://www.adobe.com/2006/mxml>
<mx:VBox>
<mx:Label text="Label 1" />
<mx:Label text="Label 2" />
</mx:VBox>
</mx:Application>
39. Set the recycleChildren property to true to improve a Repeater object's performance (re-uses previously created children instead of creating new ones)
<mx:Script>
<![CDATA[
[Bindable]
public var repeaterData : Array = ["data 1", "data 2"];
]]>
</mx:Script>
<mx:Repeater id="repeater" dataProvider="{repeaterData}">
<mx:Label text="data item: {repeater.currentItem}"/>
</mx:Repeater>
40. Keep framerate set at 60 fps or lower
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx=http://www.adobe.com/2006/mxml
frameRate="45">
</mx:Application>
41. Avoid multiple display manipulations per frame
42. Code against ENTER_FRAME events instead of Timer events
public function onEnterFrame( event : Event ) : void
{
}
private function init() : void
{
addEventListener( Event.ENTER_FRAME, onEnterFrame );
}
NOT:
public function onTimerTick( event : Event ) : void
{
}
private function init() : void
{
var timer : Timer = new Timer();
timer.start();
timer.addEventListener( TimerEvent.TIMER, onTimerTick );
}
43. To defer object creation over multiple frames use:
<mx:Container creationPolicy=”queued”/>
44. Alpha = 0 is not the same as visible = false (Objects marked invisible are passed over)
loginButton.visible = false;
NOT:
loginButton.alpha = 0;
45. Faster to perform operations locally than it is to call a function in the same class Even slower to call a function from a different class (This is referred to as “code inlining”.)
46. When executing a function it’s more expensive if you call other functions from within it
private function udpateUserRecord()
{
update( user.firstName + user.lastName );
}
NOT:
private function updateUserRecord() {
update( concatName() );
}
private function concatName() : String
{
return user.firstName + user.lastName;
}
47. Arguments in functions are slower than a reference to an objects variables
package com.seantheflexguy.as3optimization
{
public class DemoClassMemberVariables
{
// set the properties on class instances
public var userName : String;
// etc...
public function DemoClassMemberVariables()
{
}
private function login() : void
{
// login implementation logic
userName = creds.getUserName();
// etc...
}
}
}
NOT:
package com.seantheflexguy.as3optimization
{
public class DemoClassArguments
{
public function DemoClassArguments()
{
}
private function login( creds : Authentication ) : void
{
// login implementation logic
userName = creds.getUserName();
// etc...
}
}
}
48. Faster to use "as" vs. casting
var u : User = event.results.users.user as User;
NOT:
var u : User = User(event.results.users.user);
49. Use custom object types vs new Object();
var v3D : Vector3D = new Vector3D();
v3D.x = 100;
v3D.y = 450;
v3D.z = 500;
NOT:
var v3DObject : Object = new Object();
v3DObject.x = 100;
v3DObject.y = 450;
v3DObject.z = 500;
50. Use casting to inform the Flash player what kind of objects are inside an Array
for (i=0;i<n;i++)
{
Vector3D( array[i] ).x = 2;
}
NOT:
for (i=0;i<n;i++)
{
array[i].x = 2;
}
51. Check for null instead of using try...catch blocks
if ( o != null )
{
o.method();
}
NOT:
try
{
o.method();
}
catch ( error )
{
trace( error );
}
一部分的中文
http://blog.csdn.net/xiaoxin888888/archive/2009/05/18/4194426.aspx
发表评论
-
ActionScript 3.0 性能优化小知识
2010-07-30 14:12 1041http://xinsync.xju.edu.cn/in ... -
Flex企业级UI权限控制
2010-07-28 16:14 1307http://www.pin5i.com/showtopic- ... -
flex4中PopUpManager在module中有问题
2010-06-24 11:10 3148flex4中module加载module后flex4中 a ... -
Flex 开发: 类的反射
2010-06-24 10:56 1281http://www.ibm.com/developerwor ... -
Problems with ByteArray.writeObject()
2010-05-19 21:47 1732http://www.actionscript.org/for ... -
利用 E4X解决 XML 处理的性能问题
2010-05-19 21:11 1756http://www.blogjava.net/rosen/a ... -
正在安装的adobe flash player版本不是最新的版本
2010-04-22 09:56 2460打开注册表编辑器,定位到HKEY_LOCAL_MACHINE\ ... -
AS3 优化 之 FOR内循环
2010-02-10 15:39 1574写游戏只要有思路,就能实现,但这也只是从功能角度出发,能不能有 ... -
flex模块切换时导致对象不正确序列化的解决办法
2009-12-02 09:08 1631http://lkfnn.iteye.com/blog/506 ... -
漂亮的登陆
2009-11-19 16:32 1167http://dougmccune.com/360Flex_A ... -
Download all 177 Flash Effects Source Files .fla
2009-11-13 09:27 1234http://www.jeffjoneslive.com/Fl ... -
flex如何接受其他页面Post过来的数据
2009-10-10 11:15 2565问题描述: 有个程序需要调用我的flex页面,需要给我传 ... -
Change font size in the whole app with Ctrl+/-
2009-10-09 10:06 1209http://feedproxy.google.com/~r/ ... -
flex delete关键词和类成员
2009-10-09 09:01 1420flash中delete关键词用来移除定义的变量,并不能从内存 ... -
Flex HTTPService如何给后台传递参数
2009-10-09 08:56 1530http://blog.csdn.net/joeyshi/ar ... -
FLEX Builder compiler arguments 的设置
2009-09-28 08:20 1664http://flash.9ria.com/thread-18 ... -
12 Best Adobe AIR Applications for Web Designers
2009-09-25 08:20 108612 Best Adobe AIR Applications ... -
做网页如何改变IE地址栏的显示IE图标
2009-09-23 16:55 2712这个问题的解决其实在flex之外 修改index.templa ... -
Flex设置html(页面标题)title问题
2009-09-23 15:31 3293如果你是一个整体系统用了同一个标题:可以修改模板页index. ... -
flex中文问题,访问中文路径问题
2009-09-23 14:36 1210本文最先发表在本人个 ...
相关推荐
前端优化34条规则详解 #### 一、减少HTTP请求次数 - **核心概念**:HTTP请求是浏览器与服务器之间的通信过程。减少HTTP请求可以显著提升页面加载速度,因为每次请求都需要时间。 - **实践方法**: - **合并资源**...
以下是对"Oracle语句优化规则汇总"的详细解析: 一、选择正确的索引策略 1. **创建合适索引**:为经常用于查询条件的列创建索引,特别是主键和外键。复合索引可以优化多列查询。 2. **避免全表扫描**:如果索引能够...
第8条 不要进行不成熟的优化 16 第9条 不要进行不成熟的劣化 18 第10条 尽量减少全局和共享数据 19 第11条 隐藏信息 20 第12条 懂得何时和如何进行并发性编程 21 第13条 确保资源为对象所拥有。使用...
十、其他优化策略 1. 使用绑定变量:绑定变量可以避免硬解析,提高SQL执行效率。 2. 分析与重构:定期分析性能问题,对SQL语句进行重构,以适应系统变化。 总结,Oracle语句优化涉及多方面,包括索引、连接、子查询...
在基于规则的优化器中,Oracle解析器按照从右至左的顺序处理`FROM`子句中的表名。为了提升查询效率,应当确保`FROM`子句中最后出现的表(基础表driving table)具有最少的记录数。 - **实践建议:** - 当涉及多个...
3. **规则集执行协调**:提供了工具和技术来优化规则集的执行顺序,提高执行效率。 4. **规则编写与检查**:提供工具帮助开发者编写和验证规则,确保规则的有效性和正确性。 5. **规则引擎集成**:详细介绍如何将...
以上53个Oracle SQL优化规则涵盖了从SQL编写、索引设计到数据库维护的多个方面,遵循这些规则可以有效提升Oracle数据库的性能,实现更高效的数据库管理。在实际应用中,应结合具体情况进行调整和优化。
内存优化是计算机系统性能提升的重要环节,特别是在处理大数据量、多线程或高并发应用时,内存管理的有效性直接影响到程序的运行效率和系统的稳定性。本文将深入探讨内存优化的相关知识点,帮助你更好地理解并实践...
- **要点**: 在基于规则的优化器(RBO)中,Oracle解析器从右至左处理FROM子句中的表名。为了提高性能,应将记录条数最少的表放在最后,即作为基础表。如果有多于三个表的连接查询,则应选择交叉表作为基础表。交叉...
#### 十、针对代码大小的优化 1. **选择较短的指令**:使用更短的指令来减少代码大小。 2. **使用较短的常量和地址**:采用更紧凑的方式来表示常量和地址。 3. **复用常量**:尽可能复用相同的常量值以减少代码...
以下是对【标题】"学习C++的五十条规则"的详细解读: 1. 将C++视为一门独立的语言,不要试图将其与C语言混为一谈,因为两者虽然有相似之处,但设计理念和特性有很大差异。 2. 推荐初学者阅读《Thinking In C++》以...
SEO(搜索引擎优化)是提升网站在搜索引擎自然搜索结果中排名的一种技术。通过对网站的各个方面进行优化,包括内容、结构和外部链接,可以增加网站的可见性和吸引更多的目标流量。以下是一些关键的SEO知识点: 1. *...
《百度官方SEO优化指南v1.0》是百度搜索引擎针对网站优化发布的一份权威文档,旨在帮助网站管理员和SEO从业者更好地理解和遵循搜索引擎的排名规则,提高网站在搜索结果中的可见性和用户体验。这份PDF版的指南详细...
其中,管加工工厂是整个生产链中最复杂的一环,它包含加厚、热处理、机加工三个主要的产区,共有十九条加工产线。通过实际数据的应用和求解过程,验证了所提模型的有效性和实用性。 #### 六、结论与展望 通过对...
标题中的"matlab优化十五"可能指的是这是一个系列教程的第十五部分,专门讨论MATLAB在无人机路径规划优化中的应用。在实际操作中,无人机的路径规划通常需要考虑多个因素,包括飞行安全、作业效率、电池续航以及作物...
飞思卡尔第十一届规则预测提供了对竞赛规则的前瞻和变化的分析,尤其是在车模、赛道、传感器等方面的新功能和要求。以下是对文档内容的详细知识点梳理: 1. 车模结构和功能更新: 飞思卡尔智能车竞赛的车模一般分为...
USB3.0(通用串行总线3.0)是一种高速接口标准,相较于之前的USB2.0,它在数据传输速度上有了显著提升,能够达到5Gbps的理论最大速率,约为USB2.0的十倍。在设计USB3.0的PCB布线时,遵循正确的布线规则至关重要,因为...