-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEecBenchmarkTest.java
48 lines (43 loc) · 1.86 KB
/
EecBenchmarkTest.java
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
import org.ttzero.excel.reader.ExcelReader;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.io.IOException;
import java.util.Comparator;
import java.util.stream.Stream;
public class EecBenchmarkTest {
public static void main(String[] args) {
eecRead(RandomDataProvider.outPath.resolve("ignore.xlsx").toFile());
eecRead(RandomDataProvider.outPath.resolve("ignore.xlsx").toFile());
eecRead(RandomDataProvider.outPath.resolve("ignore.xlsx").toFile());
eecRead(RandomDataProvider.outPath.resolve("ignore.xlsx").toFile());
if (args.length == 0) {
try (Stream<Path> stream = Files.list(RandomDataProvider.outPath)) {
stream.map(Path::toFile).filter(p -> {
int i = p.getName().lastIndexOf(".xls"), n = p.getName().length();
return i == n - 4 || i == n - 5;
})
.sorted(Comparator.comparingLong(File::length))
.forEach(EecBenchmarkTest::eecRead);
} catch (IOException e) {
e.printStackTrace();
}
} else {
for (String file : args) {
eecRead(RandomDataProvider.outPath.resolve(file).toFile());
}
}
}
/**
* 读取并转对象,输出总行数(不包含表头)
*/
private static void eecRead(File file) {
long start = System.currentTimeMillis(), n = 0;
try (ExcelReader reader = ExcelReader.read(file.toPath())) {
n = reader.sheet(0).header(1).bind(LargeData.class).rows().map(org.ttzero.excel.reader.Row::get).count();
} catch (Exception e) {
e.printStackTrace();
}
RandomDataProvider.println("[Eec] read \"" + file.getName() + "\" finished. Rows: " + n + " Cost(ms): " + (System.currentTimeMillis() - start));
}
}