1 21 22 package org.apache.derbyTesting.unitTests.harness; 23 24 import org.apache.derby.iapi.services.monitor.Monitor; 25 import org.apache.derby.iapi.services.property.PropertyUtil; 26 27 import java.util.Properties ; 28 29 42 public abstract class T_MultiIterations extends T_Generic 43 { 44 protected T_MultiIterations() 45 { 46 super(); 47 } 48 49 52 53 54 60 protected void runTests() throws T_Fail { 61 62 setupTest(); 63 64 int iterations = 1; 65 66 72 String myClass = this.getClass().getName(); 73 String noPackage = myClass.substring(myClass.lastIndexOf('.') + 1); 74 String propertyName = "derby." + noPackage + ".iterations"; 75 76 String iter = PropertyUtil.getSystemProperty(propertyName); 77 if (iter != null) { 78 try { 79 iterations = Integer.parseInt(iter); 80 } catch (NumberFormatException nfe) { 81 } 83 if (iterations <= 0) 84 iterations = 1; 85 } 86 87 for (int i = 0; i < iterations; i++) { 88 Runtime.getRuntime().gc(); 89 long btm = Runtime.getRuntime().totalMemory(); 90 long bfm = Runtime.getRuntime().freeMemory(); 91 long bum = btm - bfm; 92 93 long start = System. currentTimeMillis(); 94 95 runTestSet(); 96 97 long end = System. currentTimeMillis(); 98 99 Runtime.getRuntime().gc(); 100 long atm = Runtime.getRuntime().totalMemory(); 101 long afm = Runtime.getRuntime().freeMemory(); 102 long aum = atm - afm; 103 104 out.println("Iteration " + i + " took " + (end - start) + "ms"); 105 out.println("Total memory increased by " + (atm - btm) + " is " + atm); 106 out.println("Used memory increased by " + (aum - bum) + " is " + aum); 107 } 108 } 109 110 113 114 119 protected abstract void setupTest() throws T_Fail; 120 121 126 protected abstract void runTestSet() throws T_Fail; 127 } 128 | Popular Tags |