You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by pe...@apache.org on 2014/12/03 15:38:09 UTC

git commit: [flex-asjs] [refs/heads/develop] - Added speed comparison test to ChartExample.

Repository: flex-asjs
Updated Branches:
  refs/heads/develop 1b2a501a1 -> f1b2afbe9


Added speed comparison test to ChartExample.


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/f1b2afbe
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/f1b2afbe
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/f1b2afbe

Branch: refs/heads/develop
Commit: f1b2afbe9ef3fd573359d0116d99cdb37e22d7ec
Parents: 1b2a501
Author: Peter Ent <pe...@apache.org>
Authored: Wed Dec 3 09:38:03 2014 -0500
Committer: Peter Ent <pe...@apache.org>
Committed: Wed Dec 3 09:38:03 2014 -0500

----------------------------------------------------------------------
 examples/ChartExample/src/ChartExample.mxml     |   2 +-
 examples/ChartExample/src/SpeedTestView.mxml    | 187 +++++++++++++++++++
 .../ChartExample/src/models/ProductsModel.as    |  11 +-
 3 files changed, 196 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1b2afbe/examples/ChartExample/src/ChartExample.mxml
----------------------------------------------------------------------
diff --git a/examples/ChartExample/src/ChartExample.mxml b/examples/ChartExample/src/ChartExample.mxml
index baa95f8..66b5ed9 100644
--- a/examples/ChartExample/src/ChartExample.mxml
+++ b/examples/ChartExample/src/ChartExample.mxml
@@ -31,7 +31,7 @@
 		<models:ProductsModel />
 	</basic:model>
 	<basic:initialView>
-		<local:MyInitialView />
+		<local:SpeedTestView />
 	</basic:initialView>
 </basic:Application>
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1b2afbe/examples/ChartExample/src/SpeedTestView.mxml
----------------------------------------------------------------------
diff --git a/examples/ChartExample/src/SpeedTestView.mxml b/examples/ChartExample/src/SpeedTestView.mxml
new file mode 100644
index 0000000..c1a23e1
--- /dev/null
+++ b/examples/ChartExample/src/SpeedTestView.mxml
@@ -0,0 +1,187 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<basic:ViewBase xmlns:fx="http://ns.adobe.com/mxml/2009"
+				xmlns:basic="library://ns.apache.org/flexjs/basic"
+				xmlns:local="*" 
+				xmlns:models="models.*"
+				>
+	<fx:Script>
+		<![CDATA[
+			import models.ProductsModel;
+			
+			import org.apache.flex.events.Event;
+			
+			private var startTime:Date;
+			private var endTime:Date;
+			
+			private function startTimingSVG():void
+			{
+				var n:Number = Number(numPoints.text);
+				
+				var m:ProductsModel = applicationModel as ProductsModel;
+				m.generateWaves(n);
+				
+				trace("Will start timing");
+				startTime = new Date();
+				svgChart.addEventListener("layoutComplete",wave1Complete);
+				svgChart.dataProvider = m.wave1;
+			}
+			
+			private function wave1Complete(event:org.apache.flex.events.Event):void
+			{
+				endTime = new Date();
+				var diff:Number = endTime.getTime() - startTime.getTime();
+				svgChartResults.text = diff+" msecs";
+			}
+			
+			private function startTimingReg():void
+			{
+				var n:Number = Number(numPoints.text);
+				
+				var m:ProductsModel = applicationModel as ProductsModel;
+				m.generateWaves(n);
+				
+				trace("Will start timing");
+				startTime = new Date();
+				regChart.addEventListener("layoutComplete",wave2Complete);
+				regChart.dataProvider = m.wave1;
+			}
+			
+			private function wave2Complete(event:org.apache.flex.events.Event):void
+			{
+				endTime = new Date();
+				var diff:Number = endTime.getTime() - startTime.getTime();
+				regChartResults.text = diff+" msecs";
+			}
+		]]>
+	</fx:Script>
+	
+	<fx:Style>
+		@namespace models "models.*";
+		@namespace basic "library://ns.apache.org/flexjs/basic";
+		
+		.hsline {
+			IDataGroup: ClassReference("org.apache.flex.charts.optimized.SVGChartDataGroup");
+			IHorizontalAxisGroup: ClassReference("org.apache.flex.charts.optimized.SVGChartAxisGroup");
+			IVerticalAxisGroup: ClassReference("org.apache.flex.charts.optimized.SVGChartAxisGroup");
+		}
+	</fx:Style>
+	
+	<basic:Container x="20" y="20">
+		<basic:beads>
+			<basic:NonVirtualHorizontalLayout />
+		</basic:beads>
+		<basic:Label text="Points:" />
+		<basic:TextInput id="numPoints" text="300" />
+	</basic:Container>
+	
+	<!-- SVG Line Chart -->
+	
+	<basic:Label text="SVG Chart" x="250" y="80" />
+	
+	<basic:LineChart id="svgChart" x="21" y="100" width="400" height="200" className="hsline">
+		<basic:beads>
+			<!--<basic:ConstantBinding
+				sourceID="applicationModel"
+				sourcePropertyName="wave"
+				destinationPropertyName="dataProvider" />-->
+			<basic:HorizontalLinearAxisBead valueField="x" />
+			<basic:VerticalLinearAxisBead valueField="sin" />
+			<basic:LineChartLinearVsLinearLayout />
+		</basic:beads>
+		<basic:series>
+			<basic:LineSeries xField="x" yField="sin">
+				<basic:itemRenderer>
+					<fx:Component>
+						<basic:SVGBoxItemRenderer>
+							<basic:fill>
+								<basic:SolidColor color="#FF44FF" alpha="1" />
+							</basic:fill>  
+						</basic:SVGBoxItemRenderer>
+					</fx:Component>
+				</basic:itemRenderer>
+				<basic:lineSegmentRenderer>
+					<fx:Component>
+						<basic:SVGLineSegmentItemRenderer>
+							<basic:stroke>
+								<basic:SolidColorStroke color="#964DFF" weight="2" alpha="1" />
+							</basic:stroke>
+						</basic:SVGLineSegmentItemRenderer>                        
+					</fx:Component>
+				</basic:lineSegmentRenderer>
+			</basic:LineSeries>
+		</basic:series>
+	</basic:LineChart>
+	
+	<!-- Regular Line Chart -->
+	
+	<basic:Label text="Reg Chart" x="650" y="80" />
+	
+	<basic:LineChart id="regChart" x="500" y="100" width="400" height="200">
+		<basic:beads>
+			<!--<basic:ConstantBinding
+				sourceID="applicationModel"
+				sourcePropertyName="wave2"
+				destinationPropertyName="dataProvider" />-->
+			<basic:HorizontalLinearAxisBead valueField="x" />
+			<basic:VerticalLinearAxisBead valueField="sin" />
+			<basic:LineChartLinearVsLinearLayout />
+		</basic:beads>
+		<basic:series>
+			<basic:LineSeries xField="x" yField="sin">
+				<basic:itemRenderer>
+					<fx:Component>
+						<basic:BoxItemRenderer>
+							<basic:fill>
+								<basic:SolidColor color="#99FF99" alpha="1" />
+							</basic:fill>  
+						</basic:BoxItemRenderer>
+					</fx:Component>
+				</basic:itemRenderer>
+				<basic:lineSegmentRenderer>
+					<fx:Component>
+						<basic:LineSegmentItemRenderer>
+							<basic:stroke>
+								<basic:SolidColorStroke color="#33DD33" weight="2" alpha="1" />
+							</basic:stroke>
+						</basic:LineSegmentItemRenderer>                        
+					</fx:Component>
+				</basic:lineSegmentRenderer>
+			</basic:LineSeries>
+		</basic:series>
+	</basic:LineChart>
+	
+	<basic:Container x="150" y="325">
+		<basic:beads>
+			<basic:NonVirtualHorizontalLayout />
+		</basic:beads>
+		<basic:TextButton text="SVG Go" click="startTimingSVG()" />
+		<basic:Label text="  (results)" id="svgChartResults" />
+	</basic:Container>
+	
+	<basic:Container x="650" y="325">
+		<basic:beads>
+			<basic:NonVirtualHorizontalLayout />
+		</basic:beads>
+		<basic:TextButton text="Reg Go" click="startTimingReg()" />
+		<basic:Label text="  (results)" id="regChartResults" />
+	</basic:Container>
+	
+</basic:ViewBase>

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/f1b2afbe/examples/ChartExample/src/models/ProductsModel.as
----------------------------------------------------------------------
diff --git a/examples/ChartExample/src/models/ProductsModel.as b/examples/ChartExample/src/models/ProductsModel.as
index ee5a5e1..c173c6e 100644
--- a/examples/ChartExample/src/models/ProductsModel.as
+++ b/examples/ChartExample/src/models/ProductsModel.as
@@ -26,7 +26,7 @@ package models
 	{
 		public function ProductsModel()
 		{
-			generateWaves(360);
+			generateWaves(20);
 		}
 
 		private var _productList:Array = [
@@ -49,7 +49,7 @@ package models
 		
 		private var _wave:Array;
 		
-		private function generateWaves(numPoints:int):void
+		public function generateWaves(numPoints:int):void
 		{
 			_wave = [];
 			
@@ -66,7 +66,12 @@ package models
 			}
 		}
 		
-		public function get wave():Array
+		public function get wave1():Array
+		{
+			return _wave;
+		}
+		
+		public function get wave2():Array
 		{
 			return _wave;
 		}