Refactor SSPerformanceTest into a few methods to make it easier to use a profiler
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742420 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f688ed96c6
commit
26de463419
@ -44,6 +44,17 @@ public class SSPerformanceTest {
|
|||||||
int cols = parseInt(args[2], "Failed to parse cols value as integer");
|
int cols = parseInt(args[2], "Failed to parse cols value as integer");
|
||||||
boolean saveFile = parseInt(args[3], "Failed to parse saveFile value as integer") != 0;
|
boolean saveFile = parseInt(args[3], "Failed to parse saveFile value as integer") != 0;
|
||||||
|
|
||||||
|
addContent(workBook, isHType, rows, cols);
|
||||||
|
|
||||||
|
if (saveFile) {
|
||||||
|
String fileName = type + "_" + rows + "_" + cols + "." + getFileSuffix(args[0]);
|
||||||
|
saveFile(workBook, fileName);
|
||||||
|
}
|
||||||
|
long timeFinished = System.currentTimeMillis();
|
||||||
|
System.out.println("Elapsed " + (timeFinished-timeStarted)/1000 + " seconds");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addContent(Workbook workBook, boolean isHType, int rows, int cols) {
|
||||||
Map<String, CellStyle> styles = createStyles(workBook);
|
Map<String, CellStyle> styles = createStyles(workBook);
|
||||||
|
|
||||||
Sheet sheet = workBook.createSheet("Main Sheet");
|
Sheet sheet = workBook.createSheet("Main Sheet");
|
||||||
@ -68,6 +79,13 @@ public class SSPerformanceTest {
|
|||||||
|
|
||||||
Row row = sheet.createRow(rowIndexInSheet);
|
Row row = sheet.createRow(rowIndexInSheet);
|
||||||
for (int colIndex = 0; colIndex < cols; colIndex++) {
|
for (int colIndex = 0; colIndex < cols; colIndex++) {
|
||||||
|
value = populateCell(styles, value, calendar, rowIndex, row, colIndex);
|
||||||
|
}
|
||||||
|
rowIndexInSheet++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double populateCell(Map<String, CellStyle> styles, double value, Calendar calendar, int rowIndex, Row row, int colIndex) {
|
||||||
Cell cell = row.createCell(colIndex);
|
Cell cell = row.createCell(colIndex);
|
||||||
String address = new CellReference(cell).formatAsString();
|
String address = new CellReference(cell).formatAsString();
|
||||||
switch (colIndex){
|
switch (colIndex){
|
||||||
@ -110,11 +128,10 @@ public class SSPerformanceTest {
|
|||||||
cell.setCellValue(value++);
|
cell.setCellValue(value++);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
rowIndexInSheet++;
|
|
||||||
}
|
private static void saveFile(Workbook workBook, String fileName) {
|
||||||
if (saveFile) {
|
|
||||||
String fileName = type + "_" + rows + "_" + cols + "." + getFileSuffix(args[0]);
|
|
||||||
try {
|
try {
|
||||||
FileOutputStream out = new FileOutputStream(fileName);
|
FileOutputStream out = new FileOutputStream(fileName);
|
||||||
workBook.write(out);
|
workBook.write(out);
|
||||||
@ -123,9 +140,6 @@ public class SSPerformanceTest {
|
|||||||
System.err.println("Error: failed to write to file \"" + fileName + "\", reason=" + ioe.getMessage());
|
System.err.println("Error: failed to write to file \"" + fileName + "\", reason=" + ioe.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long timeFinished = System.currentTimeMillis();
|
|
||||||
System.out.println("Elapsed " + (timeFinished-timeStarted)/1000 + " seconds");
|
|
||||||
}
|
|
||||||
|
|
||||||
static Map<String, CellStyle> createStyles(Workbook wb) {
|
static Map<String, CellStyle> createStyles(Workbook wb) {
|
||||||
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
|
||||||
|
Loading…
Reference in New Issue
Block a user