|
|
@ -32,6 +32,7 @@ public class LargeDataTest { |
|
|
|
private static File template07; |
|
|
|
private static File template07; |
|
|
|
private static File fileCsv; |
|
|
|
private static File fileCsv; |
|
|
|
private static File fileWrite07; |
|
|
|
private static File fileWrite07; |
|
|
|
|
|
|
|
private static File fileWriteTemp07; |
|
|
|
private static File fileWritePoi07; |
|
|
|
private static File fileWritePoi07; |
|
|
|
|
|
|
|
|
|
|
|
private int i = 0; |
|
|
|
private int i = 0; |
|
|
@ -40,6 +41,7 @@ public class LargeDataTest { |
|
|
|
public static void init() { |
|
|
|
public static void init() { |
|
|
|
fileFill07 = TestFileUtil.createNewFile("largefill07.xlsx"); |
|
|
|
fileFill07 = TestFileUtil.createNewFile("largefill07.xlsx"); |
|
|
|
fileWrite07 = TestFileUtil.createNewFile("large" + File.separator + "fileWrite07.xlsx"); |
|
|
|
fileWrite07 = TestFileUtil.createNewFile("large" + File.separator + "fileWrite07.xlsx"); |
|
|
|
|
|
|
|
fileWriteTemp07 = TestFileUtil.createNewFile("large" + File.separator + "fileWriteTemp07.xlsx"); |
|
|
|
fileWritePoi07 = TestFileUtil.createNewFile("large" + File.separator + "fileWritePoi07.xlsx"); |
|
|
|
fileWritePoi07 = TestFileUtil.createNewFile("large" + File.separator + "fileWritePoi07.xlsx"); |
|
|
|
template07 = TestFileUtil.readFile("large" + File.separator + "fill.xlsx"); |
|
|
|
template07 = TestFileUtil.readFile("large" + File.separator + "fill.xlsx"); |
|
|
|
fileCsv = TestFileUtil.createNewFile("largefileCsv.csv"); |
|
|
|
fileCsv = TestFileUtil.createNewFile("largefileCsv.csv"); |
|
|
@ -47,7 +49,6 @@ public class LargeDataTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void t01Read() throws Exception { |
|
|
|
public void t01Read() throws Exception { |
|
|
|
Thread.sleep(10*1000L); |
|
|
|
|
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
EasyExcel.read(TestFileUtil.getPath() + "large" + File.separator + "large07.xlsx", LargeData.class, |
|
|
|
EasyExcel.read(TestFileUtil.getPath() + "large" + File.separator + "large07.xlsx", LargeData.class, |
|
|
|
new LargeDataListener()).headRowNumber(2).sheet().doRead(); |
|
|
|
new LargeDataListener()).headRowNumber(2).sheet().doRead(); |
|
|
@ -86,9 +87,16 @@ public class LargeDataTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void t04Write() throws Exception { |
|
|
|
public void t04Write() throws Exception { |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
ExcelWriter excelWriter = EasyExcel.write(fileWriteTemp07, LargeData.class).build(); |
|
|
|
ExcelWriter excelWriter = EasyExcel.write(fileWrite07, LargeData.class).build(); |
|
|
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
|
|
|
|
for (int j = 0; j < 2; j++) { |
|
|
|
|
|
|
|
excelWriter.write(data(), writeSheet); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
excelWriter.finish(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
|
|
|
|
excelWriter = EasyExcel.write(fileWrite07, LargeData.class).build(); |
|
|
|
|
|
|
|
writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
for (int j = 0; j < 100; j++) { |
|
|
|
for (int j = 0; j < 100; j++) { |
|
|
|
excelWriter.write(data(), writeSheet); |
|
|
|
excelWriter.write(data(), writeSheet); |
|
|
|
LOGGER.info("{} write success.", j); |
|
|
|
LOGGER.info("{} write success.", j); |
|
|
@ -116,7 +124,8 @@ public class LargeDataTest { |
|
|
|
} |
|
|
|
} |
|
|
|
long costPoi = System.currentTimeMillis() - start; |
|
|
|
long costPoi = System.currentTimeMillis() - start; |
|
|
|
LOGGER.info("poi write cost:{}", System.currentTimeMillis() - start); |
|
|
|
LOGGER.info("poi write cost:{}", System.currentTimeMillis() - start); |
|
|
|
Assert.assertTrue(costPoi * 3 > cost); |
|
|
|
LOGGER.info("{} vs {}", cost, costPoi); |
|
|
|
|
|
|
|
Assert.assertTrue(costPoi * 2 > cost); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<LargeData> data() { |
|
|
|
private List<LargeData> data() { |
|
|
|