changeset 197:2b28d3c16a58 working

use list-capacity
author e095732
date Fri, 15 Mar 2013 17:25:25 +0900
parents caee170e6cfa
children f151dea22b2c
files src/alice/test/codesegment/local/StartCodeSegment.java src/alice/test/codesegment/local/TestCodeSegment.java src/alice/test/codesegment/local/bitonicsort/DataList.java src/alice/test/codesegment/local/bitonicsort/SetInfo.java
diffstat 4 files changed, 23 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/test/codesegment/local/StartCodeSegment.java	Tue Mar 12 13:49:48 2013 +0900
+++ b/src/alice/test/codesegment/local/StartCodeSegment.java	Fri Mar 15 17:25:25 2013 +0900
@@ -1,42 +1,20 @@
 package alice.test.codesegment.local;
 
-import java.util.Random;
-
 import alice.codesegment.CodeSegment;
-import alice.test.codesegment.local.bitonicsort.DataList;
 
 public class StartCodeSegment extends CodeSegment {
 
-	
-	public static long t = 0; 
 	@Override
 	public void run() {
 		System.out.println("run StartCodeSegment");
 		
-		/*
 		TestCodeSegment cs = new TestCodeSegment();
 		cs.arg1.setKey("key1"); // unbound datasegment key1 is created and connect to cs.
 								// cs is waiting for local.key1
-		ods.update("local", "key1", 0);  // bind string data to datasegment local.key1
-										 // this startup TestCodeSegment.  
-		*/
-		DataList list = new DataList();
-		int size = 10000;
-		for (int i = 0; i < size; i++){
-			Random rnd = new Random();
-			list.table.add(rnd.nextInt(100000));
-		}
-		t = System.currentTimeMillis();
-		ods.put("local","key1", list);
-		//ods.put("local", "key1", 1);
-		//ods.put("local", "key1", 2);
-		//ods.put("local", "key1", 3);
+		System.out.println("create TestCodeSegment");
 		
-		new TestCodeSegment();
-		//System.out.println("create TestCodeSegment");
-		//ods.update("local", "key1", 0);
-													
+		ods.update("local", "key1", "String data"); // bind string data to datasegment local.key1
+													// this startup TestCodeSegment.
  	}
 
-	
 }
--- a/src/alice/test/codesegment/local/TestCodeSegment.java	Tue Mar 12 13:49:48 2013 +0900
+++ b/src/alice/test/codesegment/local/TestCodeSegment.java	Fri Mar 15 17:25:25 2013 +0900
@@ -6,40 +6,25 @@
 
 public class TestCodeSegment extends CodeSegment {
 	
-	static int count = 0;
-	static long y =0;
 	// create input datasegment arg1
 	Receiver arg1 = ids.create(CommandType.PEEK);
-	public TestCodeSegment(){
-		arg1.setKey("key1");
-	}
-	public TestCodeSegment(int index){
-		arg1.setKey("key1",index);
-	}
 	
 	@Override
 	public void run() {
-		if(count > 100000){
-			System.out.println(System.currentTimeMillis() - StartCodeSegment.t);
-			//System.out.println(TestCodeSegment.y );
-			System.exit(1);
+		System.out.println("index = " + arg1.index);
+		System.out.println("data = " + arg1.val);
+		System.out.println(arg1.val.getType());
+		
+		if (arg1.index == 10) {
+			System.exit(0);
+			return;
 		}
-		//DataList list = arg1.asClass(DataList.class);
-		//System.out.println(list.table);
-		//System.out.println(arg1.val);
-		//long u = System.currentTimeMillis();
-		//int i = arg1.asInteger()+1;
-		//TestCodeSegment.y +=( System.currentTimeMillis() - u); 
-		ods.update("local", "key1", arg1.val);
 		
-		new TestCodeSegment();
-		
-		//new TestCodeSegment(arg1.index);
+		TestCodeSegment cs = new TestCodeSegment();
+		cs.arg1.setKey("key1", arg1.index);
 		
-		count++;
 		// DataSegment.get("local").update
-		//ods.update("local", "key1", arg1.index);
-		
+		ods.update("local", "key1", "String data");
 	}
 
 }
--- a/src/alice/test/codesegment/local/bitonicsort/DataList.java	Tue Mar 12 13:49:48 2013 +0900
+++ b/src/alice/test/codesegment/local/bitonicsort/DataList.java	Fri Mar 15 17:25:25 2013 +0900
@@ -10,16 +10,22 @@
 @Message
 public class DataList {
 
-	public List<Integer> table = new ArrayList<Integer>();
+	public List<Integer> table;
 	
-	public DataList(){};
+	public DataList(){
+		table = new ArrayList<Integer>();
+	}
+	
+	public DataList(int size){
+		table = new ArrayList<Integer>(size);
+	}
 	
 	public DataList(List<Integer> numbers){
 		table = numbers;
 	}
 	
 	public DataList createDataList(int start, int size){
-		List<Integer> table2 = new ArrayList<Integer>();
+		List<Integer> table2 = new ArrayList<Integer>(size);
 		ListIterator<Integer> iter = table.listIterator(start);
 		for (int i=start;i<(start+size);i++){
 			table2.add(iter.next());
--- a/src/alice/test/codesegment/local/bitonicsort/SetInfo.java	Tue Mar 12 13:49:48 2013 +0900
+++ b/src/alice/test/codesegment/local/bitonicsort/SetInfo.java	Fri Mar 15 17:25:25 2013 +0900
@@ -12,7 +12,7 @@
 	@Override
 	public void run() {
 		ods.put("local", "sortconf", conf);
-		ods.put("local", "data", new DataList());
+		ods.put("local", "data", new DataList(conf.length));
 		
 		new MakeData();
 		new SetTask();