/** getDate. */
 public void addGetDate() {
   PerformanceComparisonTestCase test =
       new PerformanceComparisonTestCase() {
         public void test() throws Exception {
           PreparedStatement statement = connection.prepareStatement(sql);
           ResultSet result = statement.executeQuery();
           int size = result.getMetaData().getColumnCount();
           Vector rows = new Vector();
           while (result.next()) {
             Vector row = new Vector(size);
             for (int column = 1; column <= size; column++) {
               Object value = result.getDate(column);
               value =
                   ConversionManager.getDefaultManager()
                       .convertObject(value, ClassConstants.SQLDATE);
               row.add(value);
             }
             rows.add(row);
           }
           result.close();
           statement.close();
         }
       };
   test.setAllowableDecrease(5);
   test.setName("GetDateTest");
   addTest(test);
 }
 /** Read all employees with scrollable cursor. */
 public void addReadAllScrollableCursorTest() {
   PerformanceComparisonTestCase test =
       new PerformanceComparisonTestCase() {
         public void test() {
           ReadAllQuery query = new ReadAllQuery(Employee.class);
           query.useScrollableCursor();
           Cursor cursor = (Cursor) getSession().executeQuery(query);
           cursor.close();
         }
       };
   test.setName("ReadAllScrollableCursorTest");
   test.setAllowableDecrease(50);
   addTest(test);
 }
 /** Read all employees in-memory. */
 public void addReadAllInMemoryTest() {
   PerformanceComparisonTestCase test =
       new PerformanceComparisonTestCase() {
         public void test() {
           ReadAllQuery query = new ReadAllQuery(Employee.class);
           ExpressionBuilder builder = new ExpressionBuilder();
           query.setSelectionCriteria(builder.get("salary").greaterThan(0));
           query.checkCacheOnly();
           List results = (List) getSession().executeQuery(query);
         }
       };
   test.setName("ReadAllInMemoryTest");
   test.setAllowableDecrease(2000);
   addTest(test);
 }
예제 #4
0
 /** LinkedList. */
 public void addLinkedListTest() {
   PerformanceComparisonTestCase test =
       new PerformanceComparisonTestCase() {
         public void test() {
           List list = new LinkedList();
           for (int index = 0; index < size; index++) {
             list.add(new Integer(index));
           }
           for (int index = 0; index < size; index++) {
             Object result = list.get(index);
           }
         }
       };
   test.setName("LinkedListTest");
   test.setAllowableDecrease(-150);
   addTest(test);
 }
 /** Print through converting to calendar. */
 public void addCalendarPrintTest() {
   PerformanceComparisonTestCase test =
       new PerformanceComparisonTestCase() {
         public void test() {
           Calendar calendar = Calendar.getInstance();
           calendar.setTime(DatePrintingTest.this.date);
           StringWriter writer = new StringWriter();
           writer.write(String.valueOf(calendar.get(Calendar.YEAR)));
           writer.write(String.valueOf(calendar.get(Calendar.DATE)));
           writer.write(String.valueOf(calendar.get(Calendar.MONTH)));
           writer.write(String.valueOf(calendar.get(Calendar.HOUR)));
           writer.write(String.valueOf(calendar.get(Calendar.MINUTE)));
           writer.write(String.valueOf(calendar.get(Calendar.SECOND)));
           writer.toString();
         }
       };
   test.setName("CalendarPrintTest");
   // test.setAllowableDecrease(-50);
   addTest(test);
 }