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;
* @author Yegor Kozlov
*/
public abstract class BaseTestBugzillaIssues {
+
+ private static final POILogger logger = POILogFactory.getLogger(BaseTestBugzillaIssues.class);
private final ITestDataProvider _testDataProvider;
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);
}
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();