1.1 --- a/mdr/test/perf/src/org/netbeans/mdr/test/MDRPerformanceTests.java Mon Aug 12 09:25:08 2002 +0000
1.2 +++ b/mdr/test/perf/src/org/netbeans/mdr/test/MDRPerformanceTests.java Mon Aug 12 10:24:09 2002 +0000
1.3 @@ -35,7 +35,14 @@
1.4 import javax.jmi.model.*;
1.5
1.6 /**
1.7 - * Test case measuring object creation and deletion performance
1.8 + * Test case measuring performance of various MDR operations.
1.9 + * To run the test case, run ant with the property
1.10 + * "xtest.testtype=perf". By default, test results can be found in
1.11 + * xtest's log files. In addition, when specifying the
1.12 + * property "xtest.userdata.propertyfile=perf.properties", test
1.13 + * results are recorded in our local performace tests database.
1.14 + * The performace data stored in this database can be viewed on
1.15 + * http://beetle.czech.sun.com:8080/PerformanceChartsViewer/PerformanceChartsViewer
1.16 */
1.17 public class MDRPerformanceTests extends NbTestCase {
1.18
1.19 @@ -150,6 +157,11 @@
1.20
1.21 }
1.22
1.23 + /** Tests performance of the first MDR startup.
1.24 + * As a result 1) a total time to boot MOF within a newly created repository
1.25 + * is recorded together with 2) a total time to instantitate then the MOF
1.26 + * within the repository.
1.27 + */
1.28 public void testMDRFirstStart () {
1.29 long start = System.currentTimeMillis();
1.30 repository.getExtent(MOFMODEL);
1.31 @@ -179,6 +191,11 @@
1.32 log.println("Creating MOF instance: " + (float)result/(float)1000 + " s");
1.33 }
1.34
1.35 + /** Tests performance of the repetitional MDR startup.
1.36 + * As a result 1) a total time to obtain a reference to MOF within an already
1.37 + * existing repository is recorded together with 2) a total time to instantitate
1.38 + * then the MOF within the repository.
1.39 + */
1.40 public void testMDRStart () {
1.41 long start = System.currentTimeMillis();
1.42 repository.getExtent(MOFMODEL);
1.43 @@ -231,6 +248,14 @@
1.44 }
1.45 }
1.46
1.47 + /** Tests performance of object creation.
1.48 + * Objects are created randomly within a Java metamodel's extent.
1.49 + * As a result 1) an average time to create an object instance is recoreded
1.50 + * both excuding and including time necessary to start and finish an
1.51 + * appropriate transaction. Separately, 2) a time to create the first instance
1.52 + * of a class is recorded. This time reflects an overhead of generating handlers
1.53 + * in MDR.
1.54 + */
1.55 public void testObjectCreation () {
1.56 initSupport();
1.57 long[] results = new long[MAX_ITERATIONS];
1.58 @@ -299,6 +324,12 @@
1.59
1.60 }
1.61
1.62 + /** Tests performance of association creation.
1.63 + * Associations are created randomly within a Java metamodel's extent.
1.64 + * As a result, an average time to create an associations instance is recoreded
1.65 + * both excuding and including time necessary to start and finish an
1.66 + * appropriate transaction.
1.67 + */
1.68 public void testAssociationCreation () {
1.69 initSupport();
1.70 long[] results = new long[MAX_ITERATIONS];
1.71 @@ -365,28 +396,31 @@
1.72 log.println();
1.73 }
1.74
1.75 + /** Tests performance of the RefClass.refAllOfClass() operation.
1.76 + * All classes of the Java metamodel are queried.
1.77 + * As a result, an average time to obtain the requested collection of instances
1.78 + * of the class is recorded.
1.79 + */
1.80 public void testAllOfClass() {
1.81 initSupport();
1.82 - long[] results = new long[MAX_ITERATIONS];
1.83 - int[] nums = new int[MAX_ITERATIONS];
1.84 + int numberOfClasses = random.getNumberOfClasses();
1.85 + long[] results = new long[numberOfClasses];
1.86 System.out.println("refAllOfClass performance test started...");
1.87 - for (int i = 0; i < MAX_ITERATIONS; i++) {
1.88 + for (int i = 0; i < numberOfClasses; i++) {
1.89 System.gc();
1.90 long seed = System.currentTimeMillis();
1.91 - nums[i] = random.findAllOfClass(seed, MAX_ALL_OF_CLASS);
1.92 + random.findAllOfClass(i);
1.93 results[i] = System.currentTimeMillis() - seed;
1.94 }
1.95 System.out.println("Done.");
1.96
1.97 - int numberOfClasses = 0;
1.98 long totalTime = 0;
1.99
1.100 - for (int i = 0; i < MAX_ITERATIONS; i++) {
1.101 - numberOfClasses += nums[i];
1.102 + for (int i = 0; i < numberOfClasses; i++) {
1.103 totalTime += results[i];
1.104 if (enabled && results[i] > 0) {
1.105 PerformanceServerConnection conn = new PerformanceServerConnection();
1.106 - conn.logTestCase("MDR - 100 refAllOfClass invocations time", results[i] * 100 / nums[i]);
1.107 + conn.logTestCase("MDR - refAllOfClass invocations time", results[i]);
1.108 }
1.109 }
1.110
1.111 @@ -399,6 +433,11 @@
1.112 log.println();
1.113 }
1.114
1.115 + /** Tests performance of iterators iterating through the RefClass.refAllOfClass() operation's
1.116 + * results.
1.117 + * As a result, an average time to iterate through a collection of instances
1.118 + * of the class is recorded.
1.119 + */
1.120 public void testIteratingAllOfClass () {
1.121 initSupport();
1.122 int numberOfClasses = random.getNumberOfClasses();
1.123 @@ -436,6 +475,12 @@
1.124 log.println();
1.125 }
1.126
1.127 + /** Tests performance of the RefAssociation.refQuery(...) operation.
1.128 + * Randomly queries associations previously created within a Java metamodel's extent.
1.129 + * As a result, an average time to query a randomly selected association
1.130 + * both excluding and including time necessary to start and finish an appropriate
1.131 + * transaction is recorded.
1.132 + */
1.133 public void testQueryAssociations() {
1.134 initSupport();
1.135 long[] results = new long[MAX_ITERATIONS];
1.136 @@ -472,6 +517,12 @@
1.137 log.println();
1.138 }
1.139
1.140 + /** Tests performance of object modifications.
1.141 + * Randomly modifies objects previously created within a Java metamodel's extent.
1.142 + * As a result, an average time to modify a randomly selected attribute of a
1.143 + * randomly selected object both excluding and including time necessary to
1.144 + * start and finish an appropriate transaction is recorded.
1.145 + */
1.146 public void testObjectModification() {
1.147 initSupport();
1.148 long[] results = new long[MAX_ITERATIONS];
1.149 @@ -532,6 +583,11 @@
1.150 log.println();
1.151 }
1.152
1.153 + /** Tests performance of object modifications.
1.154 + * Randomly modifies objects previously created within a Java metamodel's extent.
1.155 + * As a result, an average time to modify a randomly selected attribute of a
1.156 + * randomly selected object within an autocommited transaction is recorded.
1.157 + */
1.158 public void testAutocommitedModifications() {
1.159 initSupport();
1.160 long[] results = new long[MAX_ITERATIONS];
1.161 @@ -572,6 +628,12 @@
1.162 log.println();
1.163 }
1.164
1.165 + /** Tests performance of object deletion.
1.166 + * Ramdomly deletes objects previously created within a Java metamodel's extent.
1.167 + * As a result, an average time to delete an object instance both excluding and
1.168 + * including time necessary to start and finish an appropriate transaction
1.169 + * is recorded.
1.170 + */
1.171 public void testObjectDeletion() {
1.172 initSupport();
1.173 long[] results = new long[MAX_DEL_ITERATIONS];
2.1 --- a/mdr/test/perf/src/org/netbeans/mdr/test/RandomDataSupport.java Mon Aug 12 09:25:08 2002 +0000
2.2 +++ b/mdr/test/perf/src/org/netbeans/mdr/test/RandomDataSupport.java Mon Aug 12 10:24:09 2002 +0000
2.3 @@ -140,12 +140,8 @@
2.4 }
2.5 }
2.6
2.7 - public int findAllOfClass(long randSeed, int max) {
2.8 - random.setSeed(randSeed);
2.9 - int bound = random.nextInt(max) + 1;
2.10 - for (int i = 0; i < bound; i++)
2.11 - allClasses[random.nextInt(allClasses.length)].refAllOfClass();
2.12 - return bound;
2.13 + public void findAllOfClass(int idx) {
2.14 + allClasses[idx].refAllOfClass();
2.15 }
2.16
2.17 public int iterateAllOfClass(int idx) {