db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattba...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker OJBPerfTest.java
Date Wed, 25 Jun 2003 17:50:04 GMT
mattbaird    2003/06/25 10:50:04

  Modified:    src/test/org/apache/ojb/performance PerfArticle.java
                        PerfHandle.java PerfArticleImpl.java
               src/schema ojbtest-schema.xml
               src/test/org/apache/ojb/broker OJBPerfTest.java
  Log:
  fixes for performance test to not use autocommit so it is a more fair comparison. Also changed
schema to NOT use BigDecimal as this can be problematic for many DB's
  
  Revision  Changes    Path
  1.4       +3 -3      db-ojb/src/test/org/apache/ojb/performance/PerfArticle.java
  
  Index: PerfArticle.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/performance/PerfArticle.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PerfArticle.java	9 Jun 2003 12:06:29 -0000	1.3
  +++ PerfArticle.java	25 Jun 2003 17:50:03 -0000	1.4
  @@ -77,9 +77,9 @@
   
       public void setMinimumStock(int minimumStock);
   
  -    public BigDecimal getPrice();
  +    public double getPrice();
   
  -    public void setPrice(BigDecimal price);
  +    public void setPrice(double price);
   
       public String getUnit();
   
  
  
  
  1.8       +2 -2      db-ojb/src/test/org/apache/ojb/performance/PerfHandle.java
  
  Index: PerfHandle.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/performance/PerfHandle.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PerfHandle.java	24 Jun 2003 16:30:42 -0000	1.7
  +++ PerfHandle.java	25 Jun 2003 17:50:03 -0000	1.8
  @@ -175,7 +175,7 @@
           PerfArticle a = newPerfArticle();
           a.setArticleName(articleName);
           a.setMinimumStock(100);
  -        a.setPrice(new BigDecimal(0.45));
  +        a.setPrice(0.45);
           a.setProductGroupId(1);
           a.setStock(234);
           a.setSupplierId(4);
  
  
  
  1.3       +5 -5      db-ojb/src/test/org/apache/ojb/performance/PerfArticleImpl.java
  
  Index: PerfArticleImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/performance/PerfArticleImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PerfArticleImpl.java	9 Jun 2003 12:06:29 -0000	1.2
  +++ PerfArticleImpl.java	25 Jun 2003 17:50:03 -0000	1.3
  @@ -67,7 +67,7 @@
       private Long articleId;
       private String articleName;
       private int minimumStock;
  -    private BigDecimal price;
  +    private double price;
       private String unit;
       private int stock;
       private int supplierId;
  @@ -77,7 +77,7 @@
       {
       }
   
  -    public PerfArticleImpl(Long articleId, String articleName, int minimumStock, BigDecimal
price, String unit, int stock, int supplierId, int productGroupId)
  +    public PerfArticleImpl(Long articleId, String articleName, int minimumStock, double
price, String unit, int stock, int supplierId, int productGroupId)
       {
           this.articleId = articleId;
           this.articleName = articleName;
  @@ -119,12 +119,12 @@
           this.minimumStock = minimumStock;
       }
   
  -    public BigDecimal getPrice()
  +    public double getPrice()
       {
           return price;
       }
   
  -    public void setPrice(BigDecimal price)
  +    public void setPrice(double price)
       {
           this.price = price;
       }
  
  
  
  1.40      +2 -2      db-ojb/src/schema/ojbtest-schema.xml
  
  Index: ojbtest-schema.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbtest-schema.xml,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- ojbtest-schema.xml	22 Jun 2003 22:03:26 -0000	1.39
  +++ ojbtest-schema.xml	25 Jun 2003 17:50:04 -0000	1.40
  @@ -612,10 +612,10 @@
       private int productGroupId;
       -->
       <table name="PERF_ARTICLE">
  -        <column name="ARTICLE_ID" required="true" primaryKey="true" type="DECIMAL"/>
  +        <column name="ARTICLE_ID" required="true" primaryKey="true" type="INTEGER"/>
           <column name="ARTICLE_NAME" type="VARCHAR" size="150"/>
           <column name="MINIMUM_STOCK" type="INTEGER"/>
  -        <column name="PRICE" type="DECIMAL"/>
  +        <column name="PRICE" type="DOUBLE"/>
           <column name="UNIT" type="VARCHAR" size="20"/>
           <column name="STOCK" type="INTEGER"/>
           <column name="SUPPLIER_ID" type="INTEGER"/>
  
  
  
  1.7       +13 -4     db-ojb/src/test/org/apache/ojb/broker/OJBPerfTest.java
  
  Index: OJBPerfTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/OJBPerfTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- OJBPerfTest.java	24 Jun 2003 16:54:18 -0000	1.6
  +++ OJBPerfTest.java	25 Jun 2003 17:50:04 -0000	1.7
  @@ -132,6 +132,7 @@
               buf.append(" (ARTICLE_ID, ARTICLE_NAME, MINIMUM_STOCK, PRICE, UNIT, STOCK,
SUPPLIER_ID)");
               buf.append(" VALUES (?,?,?,?,?,?,?)");
               Connection con = getConnection();
  +			con.setAutoCommit(false);
               PreparedStatement stmt = con.prepareStatement(buf.toString());
               for (int i = 0; i < arr.length; i++)
               {
  @@ -141,12 +142,14 @@
                   stmt.setLong(1, article.getArticleId().longValue());
                   stmt.setString(2, article.getArticleName());
                   stmt.setInt(3, article.getMinimumStock());
  -                stmt.setBigDecimal(4, article.getPrice());
  +                stmt.setDouble(4,article.getPrice());
                   stmt.setString(5, article.getUnit());
                   stmt.setInt(6, article.getStock());
                   stmt.setInt(7, article.getSupplierId());
                   stmt.executeUpdate();
               }
  +			con.commit();
  +			con.setAutoCommit(true);
               stmt.close();
               releaseConnection();
           }
  @@ -169,7 +172,7 @@
                   article.setArticleId(new Long(rs.getLong("ARTICLE_ID")));
                   article.setArticleName(rs.getString("ARTICLE_NAME"));
                   article.setMinimumStock(rs.getInt("MINIMUM_STOCK"));
  -                article.setPrice(rs.getBigDecimal("PRICE"));
  +                article.setPrice(rs.getDouble("PRICE"));
                   article.setUnit(rs.getString("UNIT"));
                   article.setStock(rs.getInt("STOCK"));
                   article.setSupplierId(rs.getInt("SUPPLIER_ID"));
  @@ -189,19 +192,22 @@
               buf.append(" SET ARTICLE_NAME = ?, MINIMUM_STOCK = ?, PRICE = ?, UNIT = ?,
STOCK = ?, SUPPLIER_ID = ?");
               buf.append(" WHERE ARTICLE_ID = ?");
               Connection con = getConnection();
  +			con.setAutoCommit(false);
               PreparedStatement stmt = con.prepareStatement(buf.toString());
               for (int i = 0; i < arr.length; i++)
               {
                   PerfArticle article = arr[i];
                   stmt.setString(1, article.getArticleName());
                   stmt.setInt(2, article.getMinimumStock());
  -                stmt.setBigDecimal(3, article.getPrice());
  +				stmt.setDouble(3, article.getPrice());
                   stmt.setString(4, article.getUnit());
                   stmt.setInt(5, article.getStock());
                   stmt.setInt(6, article.getSupplierId());
                   stmt.setLong(7, article.getArticleId().longValue());
                   stmt.executeUpdate();
               }
  +			con.commit();
  +			con.setAutoCommit(true);
               stmt.close();
               releaseConnection();
           }
  @@ -215,6 +221,7 @@
           {
               String sql = "DELETE FROM "+TABLE_NAME + " WHERE ARTICLE_ID = ?";
               Connection con = getConnection();
  +			con.setAutoCommit(false);
               PreparedStatement stmt = con.prepareStatement(sql);
               for (int i = 0; i < arr.length; i++)
               {
  @@ -222,6 +229,8 @@
                   stmt.setLong(1, article.getArticleId().longValue());
                   stmt.execute();
               }
  +			con.commit();
  +			con.setAutoCommit(true);
               stmt.close();
               releaseConnection();
           }
  
  
  

Mime
View raw message