You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by he...@apache.org on 2005/02/14 10:33:24 UTC

svn commit: r153752 [2/2] - in webservices/axis/trunk/java/dev/scratch/perf-suite: ./ axis/ axis/org/ axis/org/apache/ axis/org/apache/axis/ axis/org/apache/axis/sample/ axis/org/apache/axis/sample/echo/ axis2/ axis2/common/ common/

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/axis2/StructArraySampler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/axis2/StructArraySampler.java?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/axis2/StructArraySampler.java (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/axis2/StructArraySampler.java Mon Feb 14 01:33:15 2005
@@ -0,0 +1,77 @@
+import java.net.URL;
+
+/*
+ * Created on Feb 11, 2005
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+
+/**
+ * @author hemapani
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class StructArraySampler implements Sampler {
+    
+    private EchoStruct[] objs;
+    private EchoStruct[] results;
+    private EchoStub stub;
+    private URL url;
+    
+    public StructArraySampler(URL url){
+        this.url = url;
+    }
+
+    public void init(int arraysize) throws Exception {
+        this.objs = new EchoStruct[arraysize];
+        this.stub = new EchoStub(url);
+        for (int i = 0; i < objs.length; i++) {
+            objs[i] = new EchoStruct();
+            objs[i].setValue1("Ruy Lopez" + i);
+            objs[i].setValue2("Kings Gambit" + i);
+            objs[i].setValue3(345);
+            objs[i].setValue4("Kings Indian Defence" + i);
+            objs[i].setValue5("Musio Gambit" + i);
+            objs[i].setValue6("Benko Gambit" + i);
+            objs[i].setValue7("Secillian Defance" + i);
+            objs[i].setValue8("Queens Gambit" + i);
+            objs[i].setValue9("Queens Indian Defense" + i);
+            objs[i].setValue10("Alekine's Defense" + i);
+            objs[i].setValue11("Perc Defense" + i);
+            objs[i].setValue12("Scotch Gambit");
+            objs[i].setValue13("English Opening" + i);
+        }
+
+    }
+
+    /* (non-Javadoc)
+     * @see Sampler#invoke()
+     */
+    public void invoke() throws Exception {
+        results = stub.echoEchoStructArray(objs);
+
+    }
+
+    /* (non-Javadoc)
+     * @see Sampler#end()
+     */
+    public void end() throws Exception {
+
+        for (int i = 0; i < results.length; i++) {
+            if (!results[i].equals(objs[i])) {
+                throw new Exception("Assertion Failed");
+            }
+        }
+
+    }
+    /* (non-Javadoc)
+     * @see Sampler#createCopy()
+     */
+    public Sampler createCopy() {
+        
+        return new StructArraySampler(url);
+    }
+
+}

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/axis2/TeastAxis2.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/axis2/TeastAxis2.java?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/axis2/TeastAxis2.java (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/axis2/TeastAxis2.java Mon Feb 14 01:33:15 2005
@@ -0,0 +1,37 @@
+import java.net.URL;
+
+/*
+ * Created on Feb 11, 2005
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+
+/**
+ * @author hemapani
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class TeastAxis2 {
+
+    public static void main(String[] args) throws Exception {
+        StructArraySampler sampler =
+            new StructArraySampler(new URL(Constants.AXIS2_URL));
+        long start;
+        long end;
+//                sampler.init(1);
+//                start = System.currentTimeMillis();
+//                sampler.invoke();
+//                end = System.currentTimeMillis();
+//                sampler.end();
+        //        
+        sampler = new StructArraySampler(new URL(Constants.AXIS2_URL));
+        sampler.init(10);
+        start = System.currentTimeMillis();
+        sampler.invoke();
+        end = System.currentTimeMillis();
+        sampler.end();
+
+    }
+}

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/build.xml
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/build.xml?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/build.xml (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/build.xml Mon Feb 14 01:33:15 2005
@@ -0,0 +1,75 @@
+<project name="perf-suite" basedir="." default="test">
+	<property name="maven.repo" value="${user.home}/.maven/repository/"/>
+	<property name="build" value="build"/>
+<property name="axis.classes" value="build/axis-classes"/>
+<property name="axis2.classes" value="build/axis2-classes"/>
+	
+	<path id="axis.classpath">
+			<fileset dir="${maven.repo}">
+					<include name="axis/jars/activation.jar"/>
+					<include name="axis/jars/axis-jaxrpc-1.2-RC3.jar"/>
+					<include name="axis/jars/j2ee.jar"/>
+					<include name="axis/jars/axis-wsdl4j-1.2-RC3.jar"/>
+					<include name="axis/jars/axis-1.2-RC3.jar"/>
+					<include name="axis/jars/axis-saaj-1.2-RC3.jar"/>
+					<include name="commons-logging/jars/commons-logging-*.jar"/>
+					<include name="commons-discovery/jars/commons-discovery-*.jar"/>
+					<include name="xerces/jars/xerces*.jar"/>
+			</fileset>
+	</path>
+	<path id="axis2.classpath">
+			<fileset dir="${maven.repo}">
+				<include name="axis/jars/axis2-*.jar"/>
+				<include name="axis/jars/commons-logging-*.jar"/>
+				<include name="axis/jars/commons-discovery-*.jar"/>
+			
+				<include  name="**stax/jars/*dev*.jar"/>
+					<include  name="**stax/jars/*dev*.jar"/>
+					<include  name="**stax/jars/*api*.jar"/>
+					<include  name="**axis/jars/j2ee.jar"/>
+					<include  name="**wsdl*-RC3**.jar"/>
+			</fileset>
+	</path>
+	
+	<target name="init">
+		<mkdir dir="${build}"/>
+		<mkdir dir="${axis.classes}"/>
+		<mkdir dir="${axis2.classes}"/>
+	</target>
+	
+	<target name="compile" depends="init">
+		<javac classpath="axis.classpath" destdir="${axis.classes}">
+				<classpath refid="axis.classpath" />
+				<src path="common"/>
+				<src path="axis"/>				
+		</javac>
+		<javac classpath="axis2.classpath" destdir="${axis2.classes}">
+				<classpath refid="axis2.classpath" />
+				<src path="common"/>
+				<src path="axis2"/>				
+		</javac>
+	</target>
+	
+	<target name="axis" depends="compile">
+		<java classname="AxisTest">
+				<classpath>
+				<path  refid="axis.classpath"/>
+					<pathelement location="${axis.classes}"/>
+				</classpath>
+		</java>
+	</target>
+	
+	<target name="axis2" depends="compile">
+		<java classname="Axis2Test">
+				<classpath>
+				<path  refid="axis2.classpath"/>
+					<pathelement location="${axis2.classes}"/>
+				</classpath>
+		</java>
+	</target>
+	
+	<target name="test" depends="clean,init,compile,axis,axis2"/>
+	<target name="clean">
+		<delete  dir="${build}"></delete>
+	</target>
+</project>

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/common/Collecter.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/common/Collecter.java?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/common/Collecter.java (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/common/Collecter.java Mon Feb 14 01:33:15 2005
@@ -0,0 +1,62 @@
+import java.io.IOException;
+import java.io.Writer;
+
+/*
+ * Created on Feb 10, 2005
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class Collecter {
+    private int waitingCount = 0;
+    private int sucsess = 0;
+
+    private static Writer writer = null;
+    private long[] results;
+    private int index = 0;
+    private String message = null;
+
+    public Collecter(int size, String message, Writer writer)
+        throws IOException {
+        this.message = message;
+        Collecter.writer = writer;
+        results = new long[size];
+    }
+
+    public void add(long value) {
+        results[index] = value;
+        index++;
+    }
+
+    public synchronized void waitForMe() {
+        waitingCount++;
+
+    }
+    public synchronized void printResult() throws IOException {
+        if (waitingCount > 1) {
+            waitingCount--;
+        } else {
+            int failed = 0;
+            long totel = 0;
+
+            for (int i = 10; i < results.length; i++) {
+
+                if (results[i] == -1) {
+                    failed++;
+                } else if (results[i] > 0) {
+                    sucsess++;
+                    totel = totel + results[1];
+                }
+
+            }
+            
+            int calls = failed + sucsess;
+            double average = totel / (sucsess);
+            String result = "["+message+"], sucsess = " + sucsess + "/"+ calls + " average ( "+totel+"/"+sucsess+" )= "+ average+"\n"; 
+            System.out.println(result);
+            writer.write(result);
+            writer.flush();
+        }
+    }
+
+}

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/common/Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/common/Constants.java?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/common/Constants.java (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/common/Constants.java Mon Feb 14 01:33:15 2005
@@ -0,0 +1,17 @@
+/*
+ * Created on Feb 11, 2005
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+
+/**
+ * @author hemapani
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class Constants {
+    public static final String AXIS2_URL = "http://127.0.0.1:8080/axis2/services/echo";
+    public static final String AXIS_URL = "http://127.0.0.1:8080/axis/services/echo";
+}

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/common/EndToEndTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/common/EndToEndTest.java?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/common/EndToEndTest.java (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/common/EndToEndTest.java Mon Feb 14 01:33:15 2005
@@ -0,0 +1,55 @@
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/*
+ * Created on Feb 9, 2005
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+/**
+ * @author hemapani
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class EndToEndTest {
+    private static int numberOfRequests = 100;
+//    private int no;
+    private PrintWriter writer; 
+    private Sampler sampler; 
+    private String message;
+
+
+    public EndToEndTest(PrintWriter writer,Sampler sampler,String message){
+//        this.no = no;
+        this.sampler = sampler;
+        this.writer = writer;
+        this.message = message;
+    }
+    
+    public void invokeTest() throws IOException{
+        int[] vals = new int[]{1, 10,100,500};
+        
+        for (int j = 0; j < vals.length; j++) {
+            Collecter c = new Collecter(100,message + "Array Size =" + vals[j], writer);
+            for (int i = 0; i < numberOfRequests; i++) {
+                try {
+                    sampler.init(vals[j]);
+                    long start = System.currentTimeMillis();
+                    sampler.invoke();
+                    long end = System.currentTimeMillis();
+                    sampler.end();
+                    long time = end - start;
+                    c.add(time);
+                    System.out.println(i + " = " + time);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    e.printStackTrace(writer);
+                    c.add(-1);
+                }
+            }
+            c.printResult();
+        }
+    }
+}

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/common/LoadIncreaseTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/common/LoadIncreaseTest.java?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/common/LoadIncreaseTest.java (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/common/LoadIncreaseTest.java Mon Feb 14 01:33:15 2005
@@ -0,0 +1,76 @@
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/*
+ * Created on Feb 9, 2005
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+/**
+ * @author hemapani
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class LoadIncreaseTest {
+    private static int numberOfRequests = 100;
+    private PrintWriter writer;
+    private Sampler sampler;
+    private String message;
+    private int startTestAt = 10000;
+    private int incrementTestBy = 1000;
+
+    public LoadIncreaseTest(
+        PrintWriter writer,
+        Sampler sampler,
+        String message) {
+        this.sampler = sampler;
+        this.writer = writer;
+        this.message = message;
+    }
+
+    public void invokeTest() throws IOException {
+        int count = startTestAt;
+        while (true) {
+            count = count + incrementTestBy;
+            System.out.print("Invoke =" + count + " |");
+            writer.write("Invoke =" + count + " |");
+            try {
+                sampler.init(count);
+                sampler.invoke();
+                sampler.end();
+            } catch (Exception e) {
+                System.out.println("Failed at the size " + count);
+                writer.write("Failed at the size " + count);
+                e.printStackTrace();
+                e.printStackTrace(writer);
+                break;
+            }
+        }
+    }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/common/LoadTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/common/LoadTest.java?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/common/LoadTest.java (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/common/LoadTest.java Mon Feb 14 01:33:15 2005
@@ -0,0 +1,75 @@
+import java.io.PrintWriter;
+
+/*
+ * Created on Feb 9, 2005
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+/**
+ * @author hemapani
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class LoadTest implements Runnable {
+    private int sizeOfArray = 10;
+    private int numberOfRequests = 0;
+    private int no;
+    private PrintWriter writer;
+    private Sampler sampler;
+    private String message;
+    private Collecter c;
+
+    public LoadTest(
+        int no,
+        PrintWriter writer,
+        Sampler sampler,
+        String message,
+        Collecter c,
+        int numberOfRequests) {
+        this.sampler = sampler;
+        this.writer = writer;
+        this.message = message;
+        this.c = c;
+        this.no = no;
+        this.numberOfRequests = numberOfRequests;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Runnable#run()
+     */
+    public void run() {
+        c.waitForMe();
+        try {
+            for (int i = 0; i < numberOfRequests; i++) {
+                try {
+                    sampler.init(sizeOfArray);
+                    long start = System.currentTimeMillis();
+                    sampler.invoke();
+                    long end = System.currentTimeMillis();
+                    sampler.end();
+                    long time = end - start;
+                    c.add(time);
+                    System.out.println(
+                        "Thread" + no + " request " + i + " = " + time);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    e.printStackTrace(writer);
+                    c.add(-1);
+                    writer.flush();
+                }
+            }
+
+        } finally {
+            try {
+                c.printResult();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        System.out.println("Thread " + no + " stop");
+    }
+
+}

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/common/Sampler.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/common/Sampler.java?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/common/Sampler.java (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/common/Sampler.java Mon Feb 14 01:33:15 2005
@@ -0,0 +1,7 @@
+
+public interface Sampler {
+    public void init(int arraysize)throws Exception;
+    public void invoke()throws Exception;
+    public void end()throws Exception;
+    public Sampler createCopy();
+}

Added: webservices/axis/trunk/java/dev/scratch/perf-suite/common/TestSuite.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/perf-suite/common/TestSuite.java?view=auto&rev=153752
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/perf-suite/common/TestSuite.java (added)
+++ webservices/axis/trunk/java/dev/scratch/perf-suite/common/TestSuite.java Mon Feb 14 01:33:15 2005
@@ -0,0 +1,90 @@
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/*
+ * Created on Feb 11, 2005
+ *
+ * To change the template for this generated file go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+
+/**
+ * @author hemapani
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class TestSuite {
+    private Sampler sampler;
+    private PrintWriter writer;
+    private String message;
+    
+    public TestSuite(Sampler sampler,PrintWriter writer,String message){
+        this.sampler = sampler;
+        this.writer = writer;
+        this.message = message;
+        
+    }
+    
+    public void runSuite() throws IOException{
+       writer.write("Starting the Suite at "+ new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z").format(new Date())+"\n");
+       endToEndTest();
+        //loadIncreaseTest();
+        loadTest();
+        writer.write("Starting the Suite at "+ new SimpleDateFormat("yyyy.MM.dd G 'at' HH:mm:ss z").format(new Date())+"\n");
+    }
+    
+    private void endToEndTest() throws IOException{
+        try {
+            EndToEndTest end2endtest =
+                new EndToEndTest(writer, sampler.createCopy(), message + ",test=\"End to End Test\"");
+            end2endtest.invokeTest();
+        } catch (Exception e) {
+            e.printStackTrace();
+            writer.write("End to End test Failed\n");
+            e.printStackTrace(writer);
+            writer.flush();
+        }
+    
+    }
+    
+    private void loadTest() throws IOException{
+        int threads = 500;
+        writer.write("Starting Load test with "+threads+"\n");
+        try {
+           
+            int numberOfRequests = 10;
+            Collecter c = new Collecter(threads * numberOfRequests,"test=\"Load increase test\"",writer);
+            for (int i = 0; i < threads; i++) {
+                System.out.println("Thread "+i+ " started");
+                Thread thread = new Thread(new LoadTest(i,writer,sampler.createCopy(),message + ",test=\"Load Test\"",c,numberOfRequests));
+                thread.start();
+            }
+            writer.flush();
+        } catch (Exception e) {
+            e.printStackTrace();
+            writer.write("Load test Failed\n");
+            e.printStackTrace(writer);
+        }
+        writer.write("End Load test\n");
+        writer.flush();
+    }
+ 
+    private void loadIncreaseTest() throws IOException{
+        writer.write("Starting loadIncreaseTest\n");
+        try {
+            LoadIncreaseTest end2endtest =
+                new LoadIncreaseTest(writer, sampler.createCopy(), message + "test=\"Load increase test\"");
+            end2endtest.invokeTest();
+        } catch (Exception e) {
+            e.printStackTrace();
+            writer.write("loadIncreaseTest Failed\n");
+            e.printStackTrace(writer);
+            writer.flush();
+        }
+        writer.write("End loadIncreaseTest\n");
+        writer.flush();
+    }
+}