-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathEasyWriteBenchmarkTest.java
More file actions
57 lines (44 loc) · 1.94 KB
/
EasyWriteBenchmarkTest.java
File metadata and controls
57 lines (44 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import java.nio.file.Path;
public class EasyWriteBenchmarkTest {
public static void main(String[] args) {
warmup(); w1k(); w5k(); w10k(); w50k(); w100k(); w500k(); w1000k();
}
public static void warmup() {
for (int i = 0; i < 5; i++)
easyWrite(10, RandomDataProvider.outPath.resolve("ignore.xlsx"));
}
public static void w1k() {
easyWrite(1000, RandomDataProvider.outPath.resolve("easy-1k.xlsx"));
}
public static void w5k() {
easyWrite(5000, RandomDataProvider.outPath.resolve("easy-5k.xlsx"));
}
public static void w10k() {
easyWrite(10000, RandomDataProvider.outPath.resolve("easy-10k.xlsx"));
}
public static void w50k() {
easyWrite(50000, RandomDataProvider.outPath.resolve("easy-50k.xlsx"));
}
public static void w100k() {
easyWrite(100000, RandomDataProvider.outPath.resolve("easy-100k.xlsx"));
}
public static void w500k() {
easyWrite(500000, RandomDataProvider.outPath.resolve("easy-500k.xlsx"));
}
public static void w1000k() {
easyWrite(1000000, RandomDataProvider.outPath.resolve("easy-1000k.xlsx"));
}
private static void easyWrite(int n, Path subPath) {
long start = System.currentTimeMillis();
ExcelWriter excelWriter = EasyExcel.write(subPath.toFile()).withTemplate(RandomDataProvider.outPath.getParent().resolve("fill.xlsx").toFile()).build();
WriteSheet writeSheet = EasyExcel.writerSheet().build();
for (int j = n, p; j > 0; j -= p) {
excelWriter.fill(RandomDataProvider.randomData(p = Math.min(100, j)), writeSheet);
}
excelWriter.finish();
RandomDataProvider.println("[Easy] write \"" + subPath.getFileName() + "\" finished. Rows: " + n + " Cost(ms): " + (System.currentTimeMillis() - start));
}
}