bug 58896: write autoSizeColumn timing to POILogger instead of standard output
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1739584 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e678eeb582
commit
e66fc6b289
@ -39,6 +39,8 @@ import org.apache.poi.ss.ITestDataProvider;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.SheetUtil;
|
||||
import org.apache.poi.util.POILogFactory;
|
||||
import org.apache.poi.util.POILogger;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
@ -49,6 +51,8 @@ import org.junit.Test;
|
||||
* @author Yegor Kozlov
|
||||
*/
|
||||
public abstract class BaseTestBugzillaIssues {
|
||||
|
||||
private static final POILogger logger = POILogFactory.getLogger(BaseTestBugzillaIssues.class);
|
||||
|
||||
private final ITestDataProvider _testDataProvider;
|
||||
|
||||
@ -1427,12 +1431,13 @@ public abstract class BaseTestBugzillaIssues {
|
||||
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...");
|
||||
if (logger.check(POILogger.DEBUG)) {
|
||||
logger.log(POILogger.DEBUG, wb.getClass().getName() + " column autosizing timing...");
|
||||
}
|
||||
|
||||
final long t0 = time();
|
||||
_testDataProvider.trackAllColumnsForAutosizing(sh);
|
||||
@ -1445,24 +1450,33 @@ public abstract class BaseTestBugzillaIssues {
|
||||
}
|
||||
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...");
|
||||
if (logger.check(POILogger.DEBUG)) {
|
||||
logger.log(POILogger.DEBUG, "Populate sheet time: " + populateSheetTime + " ms (" + populateSheetTimePerCell_ns + " ns/cell)");
|
||||
|
||||
logger.log(POILogger.DEBUG, "Autosizing...");
|
||||
}
|
||||
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");
|
||||
if (logger.check(POILogger.DEBUG)) {
|
||||
logger.log(POILogger.DEBUG, "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");
|
||||
if (logger.check(POILogger.DEBUG)) {
|
||||
logger.log(POILogger.DEBUG, "Auto sizing columns took a total of " + autoSizeColumnsTime + " ms (" + autoSizeColumnsTimePerColumn + " ms per column)");
|
||||
logger.log(POILogger.DEBUG, "Best fit width time per cell: " + bestFitWidthTimePerCell_ns + " ns");
|
||||
}
|
||||
|
||||
final double totalTime_s = (populateSheetTime + autoSizeColumnsTime) / 1000;
|
||||
out.println("Total time: " + totalTime_s + " s");
|
||||
if (logger.check(POILogger.DEBUG)) {
|
||||
logger.log(POILogger.DEBUG, "Total time: " + totalTime_s + " s");
|
||||
}
|
||||
|
||||
wb.close();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user