1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
| package app.test {
import com.gskinner.utils.PerformanceTest;
import flash.display.DisplayObject;
import flash.display.InteractiveObject;
import flash.display.Sprite;
import flash.utils.setTimeout;
public class Test extends Sprite {
public var p:PerformanceTest;
public var n:Number;
public var i:int;
public var u:uint;
public var string:String;
public var sprite:Sprite;
protected var _valueNumber:Number;
protected var _valueInt:int;
protected var _valueUint:uint;
protected var _valueString:String;
protected var _valueSprite:Sprite;
public function Test() {
p = PerformanceTest.getInstance();
_valueNumber = 48151623.42;
_valueInt = 4815162342;
_valueUint = 4815162342;
_valueString = "4815162342";
_valueSprite = new Sprite();
setTimeout(run, 1000);
}
public function run ():void {
var it:uint = 1000000;
p.testFunction(testTypedNumber, it, "typed Number");
p.testFunction(testNoneNumber, it, "none Number");
p.testFunction(testCastNumber, it, "cast Number");
p.testFunction(testAsNumber, it, "as Number");
p.testFunction(testTypedInt, it, "typed int");
p.testFunction(testNoneInt, it, "none int");
p.testFunction(testCastInt, it, "cast int");
p.testFunction(testAsInt, it, "as int");
p.testFunction(testTypedUint, it, "typed uint");
p.testFunction(testNoneUint, it, "none uint");
p.testFunction(testCastUint, it, "cast uint");
p.testFunction(testAsUint, it, "as uint");
p.testFunction(testTypedString, it, "typed String");
p.testFunction(testNoneString, it, "none String");
p.testFunction(testCastString, it, "cast String");
p.testFunction(testAsString, it, "as String");
p.testFunction(testTypedSprite, it, "typed Sprite");
p.testFunction(testNoneSprite, it, "none Sprite");
p.testFunction(testCastSprite, it, "cast Sprite");
p.testFunction(testAsSprite, it, "as Sprite");
}
public function getValueTypedNumber():Number {
return _valueNumber;
}
public function getValueNumber():* {
return _valueNumber;
}
public function getValueTypedInt():int {
return _valueInt;
}
public function getValueInt():* {
return _valueInt;
}
public function getValueTypedUint():uint {
return _valueUint;
}
public function getValueUint():* {
return _valueUint;
}
public function getValueTypedString():String {
return _valueString;
}
public function getValueString():* {
return _valueString;
}
public function getValueTypedSprite():Sprite {
return _valueSprite;
}
public function getValueSprite():* {
return _valueSprite;
}
public function testTypedNumber ():void {
n = getValueTypedNumber();
}
public function testNoneNumber ():void {
n = getValueNumber();
}
public function testCastNumber ():void {
n = Number(getValueNumber());
}
public function testAsNumber ():void {
n = getValueNumber() as Number;
}
public function testTypedInt ():void {
i = getValueTypedInt();
}
public function testNoneInt ():void {
i = getValueInt();
}
public function testCastInt ():void {
i = int(getValueInt());
}
public function testAsInt ():void {
i = getValueInt() as int;
}
public function testTypedUint ():void {
u = getValueTypedUint();
}
public function testNoneUint ():void {
u = getValueUint();
}
public function testCastUint ():void {
u = int(getValueUint());
}
public function testAsUint ():void {
u = getValueUint() as int;
}
public function testTypedString ():void {
string = getValueTypedString();
}
public function testNoneString ():void {
string = getValueString();
}
public function testCastString ():void {
string = String(getValueString());
}
public function testAsString ():void {
string = getValueString() as String;
}
public function testTypedSprite ():void {
sprite = getValueTypedSprite();
}
public function testNoneSprite ():void {
sprite = getValueSprite();
}
public function testCastSprite ():void {
sprite = Sprite(getValueSprite());
}
public function testAsSprite ():void {
sprite = getValueSprite() as Sprite;
}
}
} |