On 11/17/2017 08:53 AM, Xueming Shen wrote:
3. Is ZipFile.entryNameStream really needed? Just asking because
zf.stream().map(ZipEntry::getName) is possible today.
It's not a "must" for sure. The motivation behind this is that my observation
of most normal use scenario
inside JDK is that only the "name" info is interested/collect/used. The use
pattern usually is
zf.stream().map(ZipEntry::getName)
same for the old Enumeration case, only the "name" is used and the "entry"
object is thrown away mostly.
Other than the memory consumption (showed in those two snapshots), it's also
relatively costly to create
the ZipEntry especially its "esxdostime" calculation. The jmh numbers from a
simple benchmark test
suggests the entryNameStream is about 15-20% faster. So, the only reason it's
there is for better
performance. And hope it might be useful/convenient for the end user as well.
If it's a concern, I can
hide it into the SharedSecrets, or simply use the
zf.stream().map(ZipEntry::getName) instead.
--------------------------------------
JarFileBenchmark.jf_entries avgt 20 0.871 ± 0.079 ms/op
JarFileBenchmark.jf_entryNameStream avgt 20 0.786 ± 0.165 ms/op
JarFileBenchmark.jf_getEntry avgt 20 6.805 ± 0.615 ms/op
JarFileBenchmark.jf_stream avgt 20 0.915 ± 0.096 ms/op
JarFileBenchmark.jf_versionedStream avgt 20 9.412 ± 0.642 ms/op
JarFileBenchmark.zf_entries avgt 20 0.877 ± 0.092 ms/op
JarFileBenchmark.zf_entryNameStream avgt 20 0.730 ± 0.123 ms/op
JarFileBenchmark.zf_getEntry avgt 20 1.805 ± 0.177 ms/op
JarFileBenchmark.zf_stream avgt 20 0.926 ± 0.167 ms/op
---------------------------------------
above is the numbers from a mr-jar file. here is the numbers for a normal jar.
similar difference.
# Run complete. Total time: 00:06:10
Benchmark Mode Cnt Score Error Units
JarFileBenchmark.jf_entries avgt 20 0.857 ± 0.075 ms/op
JarFileBenchmark.jf_entryNameStream avgt 20 0.691 ± 0.064 ms/op
JarFileBenchmark.jf_getEntry avgt 20 1.868 ± 0.151 ms/op
JarFileBenchmark.jf_stream avgt 20 0.857 ± 0.056 ms/op
JarFileBenchmark.jf_versionedStream avgt 20 0.875 ± 0.103 ms/op
JarFileBenchmark.zf_entries avgt 20 0.811 ± 0.061 ms/op
JarFileBenchmark.zf_entryNameStream avgt 20 0.662 ± 0.064 ms/op
JarFileBenchmark.zf_getEntry avgt 20 1.907 ± 0.259 ms/op
JarFileBenchmark.zf_stream avgt 20 0.806 ± 0.075 ms/op
sherman