db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r491786 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting: junit/ perf/basic/ perf/basic/jdbc/
Date Tue, 02 Jan 2007 12:47:48 GMT
Author: kahatlen
Date: Tue Jan  2 04:47:47 2007
New Revision: 491786

URL: http://svn.apache.org/viewvc?view=rev&rev=491786
Log:
DERBY-2200: Add performance tests to Derby using the junit perf framework

This patch (derby2200.p1.diff.txt) adds
-- few simple performance tests using the junit perf framework.
-- small addition to the reporting in JDBCPerfTestCase to indicate the
   framework the test is running in.

Patch contributed by Sunitha Kambhampati.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100IdxTestSetup.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100TestSetup.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CountTest.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CoveredIdxScan.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/HeapScan.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/SortTest.java
  (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCPerfTestCase.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/_Suite.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCPerfTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCPerfTestCase.java?view=diff&rev=491786&r1=491785&r2=491786
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCPerfTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBCPerfTestCase.java Tue
Jan  2 04:47:47 2007
@@ -159,7 +159,9 @@
         else
             total = runs[0];
 
-        System.out.println("Test-" + getName() + ":iterations: " + iterations
+        System.out.println("Test-" + getName() +
+                ": framework:"+ getTestConfiguration().getJDBCClient().getName()+
+                ":iterations: " + iterations
                 + " : Avg elapsedTime(ms): " + 
                 total / (repeats > 1 ? (long) (repeats - 1) : (long) repeats));
     }
@@ -177,9 +179,10 @@
             super.runTest();
         endTime = System.currentTimeMillis();
         runs[testRunNum] = (endTime-startTime);
-        System.out.println("Test-" + getName() + ": run#" + testRunNum
+        System.out.println("Test-" + getName() + 
+                ": framework:"+ getTestConfiguration().getJDBCClient().getName()+
+                ": run#" + testRunNum
                 + " iterations: " + iterations + " : elapsedTime(ms): "
                 + (endTime - startTime));
-        
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/_Suite.java?view=diff&rev=491786&r1=491785&r2=491786
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/_Suite.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/_Suite.java Tue Jan
 2 04:47:47 2007
@@ -37,6 +37,10 @@
         TestSuite suite = new TestSuite("BasicPerf");
         
         suite.addTest(ValuesTest.suite());
+        suite.addTest(CountTest.suite());
+        suite.addTest(HeapScan.suite());
+        suite.addTest(CoveredIdxScan.suite());
+        suite.addTest(SortTest.suite());
 
         return suite;
     }

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100IdxTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100IdxTestSetup.java?view=auto&rev=491786
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100IdxTestSetup.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100IdxTestSetup.java
Tue Jan  2 04:47:47 2007
@@ -0,0 +1,87 @@
+/*
+
+Derby - Class org.apache.derbyTesting.perf.basic.jdbc.BaseLoad100IdxTestSetup
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+package org.apache.derbyTesting.perf.basic.jdbc;
+
+import java.sql.Statement;
+import java.sql.SQLException;
+import junit.framework.Test;
+
+/**
+ * Extend the BaseLoad100TestSetup to add indexes
+ * Base table is similar to BaseLoad100TestSetup and the algorithm to load data is the same
+ * @see BaseLoad100TestSetup
+ */
+public class BaseLoad100IdxTestSetup extends BaseLoad100TestSetup {
+
+    /**
+     * constructor
+     * @param test name of the test
+     */
+    public BaseLoad100IdxTestSetup(Test test) {
+        super(test);
+    }
+
+    /**
+     * @param test name of test
+     * @param rowsToLoad number of rows to insert
+     */
+    public BaseLoad100IdxTestSetup(Test test, int rowsToLoad)
+    {
+        super(test);
+        this.rowsToLoad=rowsToLoad;
+    }
+
+    /**
+     * @param test name of the test
+     * @param tableName name of the table to insert the rows into
+     */
+    public BaseLoad100IdxTestSetup(Test test, String tableName)
+    {
+        super(test);
+        this.tableName = tableName;
+    }
+
+    /**
+     * @param test name of test
+     * @param rowsToLoad number of rows to insert
+     * @param tableName name of the table to insert the rows into
+     */
+     public BaseLoad100IdxTestSetup(Test test,int rowcount, String tableName)
+    {
+        super(test,rowcount,tableName);
+    }
+
+    /**
+     * Override the decorateSQL and create the necessary schema.
+     * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
+     */
+    protected void decorateSQL(Statement s)
+        throws SQLException
+    {
+        s.execute("CREATE TABLE " +tableName+" ("
+                + "i1 INT, i2 INT, i3 INT, i4 INT, i5 INT, "
+                + "c6 CHAR(20), c7 CHAR(20), c8 CHAR(20), c9 CHAR(20))");
+        s.execute("CREATE UNIQUE INDEX " +tableName +"x on "+ tableName+"(i1,i3)");
+
+    }
+
+
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100IdxTestSetup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100TestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100TestSetup.java?view=auto&rev=491786
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100TestSetup.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100TestSetup.java
Tue Jan  2 04:47:47 2007
@@ -0,0 +1,156 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.perf.basic.jdbc.BaseLoad100TestSetup
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derbyTesting.perf.basic.jdbc;
+
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import junit.framework.Test;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+
+/**
+ * TestSetup decorator to load the schema that is used for some of the
+ * performance tests.
+ * Schema includes:
+ * Table: is  9 column table (100bytes)  - 5 columns of type int, 4 columns of char(20)")
+ * data distribution - { column 1 has unique values,column 2 is set to 2,
+ * column 3 has 1 % of rows with same value, column 4 is set to 2,
+ * column 5 has unique values, column 6 is set to a constant value,
+ *  column 7 has 1% of rows with known pattern,
+ * column 8 has constant value,column 9 has values having the same suffix.
+ * Connection props :  autocommit - false, default isolation level- Read Committed.
+ *
+ * If any indexes have to be created or any other schema additions need to be made, then
+ * the decorateSQL() method needs to be overriden.
+ */
+public class BaseLoad100TestSetup extends CleanDatabaseTestSetup {
+
+    protected int rowsToLoad=10000;
+    protected String tableName = "BASELOAD100";
+
+    /**
+     *
+     * @param test
+     */
+    public BaseLoad100TestSetup(Test test) {
+        super(test);
+    }
+
+    /**
+     * @param test name of test
+     * @param rowsToLoad number of rows to insert
+     */
+    public BaseLoad100TestSetup(Test test, int rowsToLoad)
+    {
+        super(test);
+        this.rowsToLoad=rowsToLoad;
+    }
+
+    /**
+     * @param test name of the test
+     * @param tableName name of the table to insert the rows into
+     */
+    public BaseLoad100TestSetup(Test test, String tableName)
+    {
+        super(test);
+        this.tableName = tableName;
+    }
+
+    /**
+     * @param test name of test
+     * @param rowsToLoad number of rows to insert
+     * @param tableName name of the table to insert the rows into
+     */
+    public BaseLoad100TestSetup(Test test,int rowsToLoad, String tableName)
+    {
+        super(test);
+        this.tableName = tableName;
+        this.rowsToLoad = rowsToLoad;
+    }
+
+    /**
+     * Clean the default database using the default connection
+     * and calls the decorateSQL to allow sub-classes to
+     * initialize their schema requirments.
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        Connection conn = getConnection();
+        conn.setAutoCommit(false);
+        PreparedStatement insert = conn.prepareStatement(
+                "INSERT INTO "+tableName+" VALUES ( ?,?,?,?,?,?,?,?,? )");
+        loadData(insert);
+        insert.close();
+        conn.close();
+    }
+
+
+    /**
+     * Override the decorateSQL and create the necessary schema.
+     * @see org.apache.derbyTesting.junit.CleanDatabaseTestSetup#decorateSQL(java.sql.Statement)
+     */
+    protected void decorateSQL(Statement s)
+        throws SQLException
+    {
+        s.execute("CREATE TABLE " +tableName+" ("
+                + "i1 INT, i2 INT, i3 INT, i4 INT, i5 INT, "
+                + "c6 CHAR(20), c7 CHAR(20), c8 CHAR(20), c9 CHAR(20))");
+
+    }
+
+    /**
+     * Load the data into the table.
+     * @param insert  prepared statement to use for inserting data.
+     * @throws Exception
+     */
+    private void loadData(PreparedStatement insert) throws Exception {
+
+        for (int i = 0; i < rowsToLoad; i++) {
+            insert.setInt(1, i);
+            insert.setInt(2, 2);
+
+            // 1% of rows with a known pattern for where etc.
+            if ((i % 100) == 57)
+                insert.setInt(3, 436);
+            else
+                insert.setInt(3, 2);
+
+            insert.setInt(4, 2);
+            insert.setInt(5, i);
+            insert.setString(6, "01234567890123456789");
+
+            // 1% of rows with a known pattern for like etc.
+            if ((i % 100) == 34)
+                insert.setString(7, "012345javaone6789");
+            else
+                insert.setString(7, "01234567890123456789");
+
+            insert.setString(8, "01234567890123456789");
+
+            insert.setString(9, (i + 1000) + "0123456789012");
+            insert.executeUpdate();
+        }
+        insert.getConnection().commit();
+    }
+
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/BaseLoad100TestSetup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CountTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CountTest.java?view=auto&rev=491786
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CountTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CountTest.java
Tue Jan  2 04:47:47 2007
@@ -0,0 +1,102 @@
+/*
+
+Derby - Class org.apache.derbyTesting.perf.basic.jdbc.CountTest
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+package org.apache.derbyTesting.perf.basic.jdbc;
+
+
+import java.sql.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.JDBCPerfTestCase;
+
+/**
+ * Add tests to measure performance of count.
+ */
+public class CountTest extends JDBCPerfTestCase {
+
+    PreparedStatement select = null;
+    static String tableName = "COUNTTEST";
+    protected static int rowcount = 10000;
+
+    /**
+     * Suite of tests to return.
+     * @return
+     */
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite("CountTest");
+        int iterations = 1200, repeats = 4;
+
+        suite.addTest(new CountTest("Count100",iterations,repeats));
+        return new BaseLoad100TestSetup(suite,rowcount,tableName);
+    }
+
+    /**
+     * Constructor -create a CountTest
+     * @param name testname
+     * @param iterations iterations for the test to measure
+     * @param repeats number of times to repeat the test
+     */
+    public CountTest(String name,int iterations, int repeats)
+    {
+        super(name,iterations,repeats);
+    }
+
+    /**
+     * setup for the test.
+     **/
+    public void setUp() throws Exception {
+
+        select = openDefaultConnection().prepareStatement("SELECT COUNT(i1) FROM "+tableName);
+    }
+
+
+    /**
+     * Override initializeConnection to set the autocommit to false
+     */
+    public void initializeConnection(Connection conn)
+        throws SQLException
+    {
+        conn.setAutoCommit(false);
+    }
+
+
+    /**
+     * Execute the count query for the BaseLoad100TestSetup schema.
+     * @throws Exception
+     */
+    public void Count100() throws Exception
+    {
+        ResultSet rs = select.executeQuery();
+        rs.next();
+        assertEquals(rowcount,rs.getInt(1));
+        rs.close();
+        getConnection().commit();
+    }
+
+    /**
+     * Cleanup - close resources opened in this test.
+     **/
+    public void tearDown() throws Exception {
+        select.close();
+        select = null;
+        super.tearDown();
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CountTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CoveredIdxScan.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CoveredIdxScan.java?view=auto&rev=491786
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CoveredIdxScan.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CoveredIdxScan.java
Tue Jan  2 04:47:47 2007
@@ -0,0 +1,116 @@
+/*
+
+ Derby - Class org.apache.derbyTesting.perf.basic.jdbc.CoveredIdxScan
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ */
+package org.apache.derbyTesting.perf.basic.jdbc;
+
+
+import java.sql.*;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Index scan tests.
+ *
+ */
+public class CoveredIdxScan extends HeapScan {
+
+    /**
+     * @return suite of tests
+     */
+    public static Test suite()
+    {
+        TestSuite scan = new TestSuite("CoveredIdxScanTests");
+        int iterations = 700, repeats = 4;
+
+        scan.addTest(new CoveredIdxScan("ScanCoveredIdxInt",iterations,repeats));
+
+        return new BaseLoad100IdxTestSetup(scan,rowcount*2,tableName);
+
+
+    }
+
+    /**
+     * Constructor
+     * @param name testname
+     * @param iterations iterations for the test to measure
+     * @param repeats number of times to repeat the test
+     */
+    public CoveredIdxScan(String name,int iterations, int repeats)
+    {
+        super(name,iterations,repeats);
+    }
+
+    /**
+     * Do the necessary setup for the test ,prepare the statement
+     */
+    public void setUp() throws Exception {
+
+        select = openDefaultConnection().prepareStatement("SELECT i1 FROM "+tableName +
+        " WHERE i1 > ? and i1 <= ?");
+    }
+
+    /**
+     * Override initializeConnection to set the autocommit to false
+     */
+    public void initializeConnection(Connection conn)
+    throws SQLException
+    {
+        conn.setAutoCommit(false);
+    }
+
+
+    /**
+     * This test simply tests a covered index scan and retrieves an int column
+     * Scan starts from 1/4 into the data set and set to end 3/4 into the
+     * dataset
+     * @throws Exception
+     */
+    public void ScanCoveredIdxInt() throws Exception
+    {
+
+        // set begin scan to start 1/4 into the data set.
+        select.setInt(1, ((rowcount * 2) / 4));
+
+        // set end scan to end 3/4 into the data set.
+        select.setInt(2, (((rowcount * 2) / 4) * 3));
+
+        ResultSet rs = select.executeQuery();
+
+        int actualCount = 0;
+        int i = 0;
+        while (rs.next())
+        {
+            i = rs.getInt(1);
+            actualCount++;
+        }
+        assertEquals(rowcount,actualCount);
+        getConnection().commit();
+        rs.close();
+    }
+
+
+    /**
+     * Cleanup - close resources opened in this test.
+     */
+    public void tearDown() throws Exception {
+        super.tearDown();
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/CoveredIdxScan.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/HeapScan.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/HeapScan.java?view=auto&rev=491786
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/HeapScan.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/HeapScan.java
Tue Jan  2 04:47:47 2007
@@ -0,0 +1,141 @@
+/*
+
+Derby - Class org.apache.derbyTesting.perf.basic.jdbc.HeapScan
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+package org.apache.derbyTesting.perf.basic.jdbc;
+
+
+import java.sql.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.JDBCPerfTestCase;
+
+/**
+ * Heap Scan tests
+ *
+ */
+public class HeapScan extends JDBCPerfTestCase {
+
+    PreparedStatement select = null;
+    protected static String tableName = "SCANTEST";
+    protected static int rowcount = 10000;
+
+    /**
+     * @return suite of tests
+     */
+    public static Test suite()
+    {
+        int iterations = 700, repeats = 4;
+
+        TestSuite heapScan = new TestSuite("HeapScanTests");
+        heapScan.addTest(new HeapScan("Scan100",iterations,repeats));
+        heapScan.addTest(new HeapScan("Scan100GetData",iterations,repeats));
+        return new BaseLoad100TestSetup(heapScan,rowcount,tableName);
+    }
+
+    /**
+     * Scan tests.
+     * @param name test name
+     * @param iterations iterations of the test to measure
+     * @param repeats number of times to repeat the test
+     */
+    public HeapScan(String name,int iterations, int repeats)
+    {
+        super(name,iterations,repeats);
+    }
+
+    /**
+     * Do the necessary setup for the test ,prepare the statement
+     */
+    public void setUp() throws Exception {
+
+        select = openDefaultConnection().prepareStatement("SELECT * FROM "+tableName);
+    }
+
+
+    /**
+     * Override initializeConnection to set the autocommit to false
+     */
+    public void initializeConnection(Connection conn)
+    throws SQLException
+    {
+        conn.setAutoCommit(false);
+    }
+
+
+    /**
+     * This test simply tests a heap scan which iterates through all the
+     * rows in the columns. The column data are not retrieved using getXXX
+     * @throws Exception
+     */
+    public void Scan100() throws Exception
+    {
+
+        ResultSet rs = select.executeQuery();
+        int actualCount = 0;
+        while (rs.next()) {
+            actualCount++;
+        }
+
+        assertEquals(actualCount,rowcount);
+        rs.close();
+        getConnection().commit();
+
+    }
+
+    /**
+     * This test simply tests a heap scan which iterates through all the
+     * rows in the columns. The column data are retrieved using getXXX
+     * @throws Exception
+     */
+    public void Scan100GetData() throws Exception
+    {
+        ResultSet rs = select.executeQuery();
+
+        int actualCount = 0;
+        while (rs.next()) {
+
+            int i1 = rs.getInt(1);
+            int i2 = rs.getInt(2);
+            int i3 = rs.getInt(3);
+            int i4 = rs.getInt(4);
+            int i5 = rs.getInt(5);
+
+            String c6 = rs.getString(6);
+            String c7 = rs.getString(7);
+            String c8 = rs.getString(8);
+            String c9 = rs.getString(9);
+
+            actualCount++;
+        }
+        assertEquals(actualCount,rowcount);
+        getConnection().commit();
+        rs.close();
+    }
+
+    /**
+     * Cleanup - close resources opened in this test.
+     **/
+    public void tearDown() throws Exception {
+
+        select.close();
+        select = null;
+        super.tearDown();
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/HeapScan.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/SortTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/SortTest.java?view=auto&rev=491786
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/SortTest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/SortTest.java
Tue Jan  2 04:47:47 2007
@@ -0,0 +1,147 @@
+/*
+
+Derby - Class org.apache.derbyTesting.perf.basic.jdbc.SortTest
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+package org.apache.derbyTesting.perf.basic.jdbc;
+
+
+import java.sql.*;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.derbyTesting.junit.JDBCPerfTestCase;
+
+/**
+ * Sort test
+ *
+ */
+public class SortTest extends JDBCPerfTestCase {
+
+    PreparedStatement select = null;
+    protected static String tableName = "SORTTEST";
+    protected static int rowcount = 10000;
+
+    /**
+     * @return suite of tests
+     */
+    public static Test suite()
+    {
+        int iterations = 350, repeats = 4;
+
+        TestSuite suite = new TestSuite("SortTests");
+        suite.addTest(new SortTest("SortDesc100",iterations,repeats));
+        suite.addTest(new SortTest("SortDesc100GetData",iterations,repeats));
+        return new BaseLoad100TestSetup(suite,rowcount,tableName);
+    }
+
+    /**
+     * Sort tests.
+     * @param name test name
+     * @param iterations iterations of the test to measure
+     * @param repeats number of times to repeat the test
+     */
+    public SortTest(String name,int iterations, int repeats)
+    {
+        super(name,iterations,repeats);
+    }
+
+    /**
+     * Do the necessary setup for the test ,prepare the statement
+     */
+    public void setUp() throws Exception {
+
+        select = openDefaultConnection().prepareStatement("SELECT * FROM "+tableName +" order
by i1 desc");
+    }
+
+
+    /**
+     * Override initializeConnection to set the autocommit to false
+     */
+    public void initializeConnection(Connection conn)
+    throws SQLException
+    {
+        conn.setAutoCommit(false);
+    }
+
+
+    /**
+     * Sort test with the schema loaded as part of BaseLoad100TestSetup
+     * The rows are presented to the sorter in reverse order of the
+     * sort.  The test loads a table with rowcount keys in order, and
+     * then sorts them in descending order.
+     * The column data are not retrieved using the appropriate getXXX() methods
+     * @throws Exception
+     */
+    public void SortDesc100() throws Exception
+    {
+
+        ResultSet rs = select.executeQuery();
+        int actualCount = 0;
+        while (rs.next()) {
+            actualCount++;
+        }
+
+        assertEquals(actualCount,rowcount);
+        rs.close();
+        getConnection().commit();
+
+    }
+
+    /**
+     * Sort test with the schema loaded as part of BaseLoad100TestSetup
+     * The rows are presented to the sorter in reverse order of the
+     * sort.  The test loads a table with rowcount keys in order, and
+     * then sorts them in descending order.
+     * The column data are retrieved using the appropriate getXXX() methods
+     * @throws Exception
+     */
+    public void SortDesc100GetData() throws Exception
+    {
+        ResultSet rs = select.executeQuery();
+
+        int actualCount = 0;
+        while (rs.next()) {
+
+            int i1 = rs.getInt(1);
+            int i2 = rs.getInt(2);
+            int i3 = rs.getInt(3);
+            int i4 = rs.getInt(4);
+            int i5 = rs.getInt(5);
+
+            String c6 = rs.getString(6);
+            String c7 = rs.getString(7);
+            String c8 = rs.getString(8);
+            String c9 = rs.getString(9);
+
+            actualCount++;
+        }
+        assertEquals(actualCount,rowcount);
+        getConnection().commit();
+        rs.close();
+    }
+
+    /**
+     * Cleanup - close resources opened in this test.
+     **/
+    public void tearDown() throws Exception {
+
+        select.close();
+        select = null;
+        super.tearDown();
+    }
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/perf/basic/jdbc/SortTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message