poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1730997 - in /poi/trunk/src: ooxml/testcases/org/apache/poi/xssf/ testcases/org/apache/poi/hssf/ testcases/org/apache/poi/ss/ testcases/org/apache/poi/ss/usermodel/
Date Thu, 18 Feb 2016 03:33:26 GMT
Author: onealj
Date: Thu Feb 18 03:33:25 2016
New Revision: 1730997

URL: http://svn.apache.org/viewvc?rev=1730997&view=rev
Log:
bug 58896: add unit test to time Sheet.autoSizeColumn

Modified:
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
    poi/trunk/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java
    poi/trunk/src/testcases/org/apache/poi/ss/ITestDataProvider.java
    poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java?rev=1730997&r1=1730996&r2=1730997&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/SXSSFITestDataProvider.java Thu Feb
18 03:33:25 2016
@@ -87,6 +87,14 @@ public final class SXSSFITestDataProvide
         return wb;
     }
     
+    //************ SXSSF-specific methods ***************//
+    @Override
+    public SXSSFWorkbook createWorkbook(int rowAccessWindowSize) {
+        SXSSFWorkbook wb = new SXSSFWorkbook(rowAccessWindowSize);
+        instances.add(wb);
+        return wb;
+    }
+    
     @Override
     public void trackColumnsForAutosizing(Sheet sheet, int...columns) {
         for (int cn : columns) {
@@ -95,6 +103,12 @@ public final class SXSSFITestDataProvide
     }
     
     @Override
+    public void trackAllColumnsForAutosizing(Sheet sheet) {
+        ((SXSSFSheet)sheet).trackAllColumnsForAutoSizing();
+    }
+    //************ End SXSSF-specific methods ***************//
+    
+    @Override
     public FormulaEvaluator createFormulaEvaluator(Workbook wb) {
         return new XSSFFormulaEvaluator(((SXSSFWorkbook) wb).getXSSFWorkbook());
     }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java?rev=1730997&r1=1730996&r2=1730997&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/XSSFITestDataProvider.java Thu Feb 18
03:33:25 2016
@@ -54,8 +54,17 @@ public final class XSSFITestDataProvider
         return new XSSFWorkbook();
     }
     
+    //************ SXSSF-specific methods ***************//
+    @Override
+    public XSSFWorkbook createWorkbook(int rowAccessWindowSize) {
+        return createWorkbook();
+    }
+    
     @Override
     public void trackColumnsForAutosizing(Sheet sheet, int...columns) {}
+    @Override
+    public void trackAllColumnsForAutosizing(Sheet sheet) {}
+    //************ End SXSSF-specific methods ***************//
    
     @Override
     public FormulaEvaluator createFormulaEvaluator(Workbook wb) {

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java?rev=1730997&r1=1730996&r2=1730997&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/HSSFITestDataProvider.java Thu Feb 18 03:33:25
2016
@@ -60,8 +60,17 @@ public final class HSSFITestDataProvider
         return new HSSFWorkbook();
     }
     
+    //************ SXSSF-specific methods ***************//
+    @Override
+    public HSSFWorkbook createWorkbook(int rowAccessWindowSize) {
+        return createWorkbook();
+    }
+    
     @Override
     public void trackColumnsForAutosizing(Sheet sheet, int...columns) {}
+    @Override
+    public void trackAllColumnsForAutosizing(Sheet sheet) {}
+    //************ End SXSSF-specific methods ***************//
     
     @Override
     public FormulaEvaluator createFormulaEvaluator(Workbook wb) {

Modified: poi/trunk/src/testcases/org/apache/poi/ss/ITestDataProvider.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/ITestDataProvider.java?rev=1730997&r1=1730996&r2=1730997&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/ITestDataProvider.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/ITestDataProvider.java Thu Feb 18 03:33:25 2016
@@ -47,11 +47,22 @@ public interface ITestDataProvider {
      */
     Workbook createWorkbook();
     
+    
+    //************ SXSSF-specific methods ***************//
+    /**
+     * Provides way of creating a SXSSFWorkbook with a specific row access window size.
+     * Equivalent to createWorkbook on others.
+     * @return an instance of Workbook
+     */
+    Workbook createWorkbook(int rowAccessWindowSize);
+    
     /**
      * Only matters for SXSSF - enables tracking of the column
      *  widths so that autosizing can work. No-op on others.
      */
     void trackColumnsForAutosizing(Sheet sheet, int...columns);
+    void trackAllColumnsForAutosizing(Sheet sheet);
+    //************ End SXSSF-specific methods ***************//
 
     /**
      * Creates the corresponding {@link FormulaEvaluator} for the

Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?rev=1730997&r1=1730996&r2=1730997&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java Thu Feb
18 03:33:25 2016
@@ -1427,4 +1427,64 @@ public abstract class BaseTestBugzillaIs
 
         assertEquals("12-312-345-123", formatter.formatCellValue(cell));
     }
+    
+    @Test
+    public void test58896() throws IOException {
+        final int nrows = 160;
+        final int ncols = 139;
+        final java.io.PrintStream out = System.out;
+        
+        // Create a workbook
+        final Workbook wb = _testDataProvider.createWorkbook(nrows+1);
+        final Sheet sh = wb.createSheet();
+        out.println(wb.getClass().getName() + " column autosizing timing...");
+        
+        final long t0 = time();
+        _testDataProvider.trackAllColumnsForAutosizing(sh);
+        for (int r=0; r<nrows; r++) {
+            final Row row = sh.createRow(r);
+            for (int c=0; c<ncols; c++) {
+                final Cell cell = row.createCell(c);
+                cell.setCellValue("Cell[r="+r+",c="+c+"]");
+            }
+        }
+        final double populateSheetTime = delta(t0);
+        final double populateSheetTimePerCell_ns = (1000000 * populateSheetTime / (nrows*ncols));
+        out.println("Populate sheet time: " + populateSheetTime + " ms (" + populateSheetTimePerCell_ns
+ " ns/cell)");
+        
+        out.println("\nAutosizing...");
+        final long t1 = time();
+        for (int c=0; c<ncols; c++) {
+            final long t2 = time();
+            sh.autoSizeColumn(c);
+            out.println("Column " + c + " took " + delta(t2) + " ms");
+        }
+        final double autoSizeColumnsTime = delta(t1);
+        final double autoSizeColumnsTimePerColumn = autoSizeColumnsTime / ncols;
+        final double bestFitWidthTimePerCell_ns = 1000000 * autoSizeColumnsTime / (ncols
* nrows);
+        
+        out.println("Auto sizing columns took a total of " + autoSizeColumnsTime + " ms ("
+ autoSizeColumnsTimePerColumn + " ms per column)");
+        out.println("Best fit width time per cell: " + bestFitWidthTimePerCell_ns + " ns");
+        
+        final double totalTime_s = (populateSheetTime + autoSizeColumnsTime) / 1000;
+        out.println("Total time: " + totalTime_s + " s");
+        
+        wb.close();
+        
+        //if (bestFitWidthTimePerCell_ns > 50000) {
+        //    fail("Best fit width time per cell exceeded 50000 ns: " + bestFitWidthTimePerCell_ns
+ " ns");
+        //}
+        
+        if (totalTime_s > 10) {
+            fail("Total time exceeded 10 seconds: " + totalTime_s + " s");
+        }
+    }
+    
+    public long time() {
+        final long currentTime = System.currentTimeMillis();
+        return currentTime;
+    }
+    public double delta(long startTimeMillis) {
+        return time() - startTimeMillis;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message