[ 
https://issues.apache.org/jira/browse/COMPRESS-508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17090053#comment-17090053
 ] 

AD_LB commented on COMPRESS-508:
--------------------------------

That's too bad.
Anyway, I wanted to try out how well the library perform, to decide the order 
of fallbacks.
I've performed a test, comparing 4 cases of handling a ZIP file that is about 
100MB on Android. These are the names I chose:

# ZipFileFilter- uses ZipFile of the Android framework
# ApacheZipFileFilter - uses ZipFile of this library
# ZipInputStreamFilter - uses ZipInputStream of the Android framework
# ApacheZipArchiveInputStream - uses ZipArchiveInputStream of this library

The test goes over all of the installed apps (APK files are zip files). What it 
does is to try to parse the APK files using another library, which handles 2 
files inside each APK file (manifest file, which is usually a small XML file 
and a resources file which is usually a bit large). The number of apps is 424, 
some have multiple APK files. Total number of APK files that are parsed is 520 
. Some small, some large.

I called them "filter" because their purpose is to find specific files that 
need to be parsed.

I performed it on a relatively low end device, to see the difference better.
What I got is this result, from fastest to slowest:

ZipFileFilter
D: time taken: 67626 . handled 424 apps apks:520
D: averageTime:159.49529 per app 130.05 per APK

ApacheZipFileFilter
D: time taken: 168984 . handled 424 apps apks:520
D: averageTime:398.54718 per app 324.96924 per APK

ApacheZipArchiveInputStreamFilter
D: time taken: 229097 . handled 424 apps apks:520
D: averageTime:540.3231 per app 440.57117 per APK

ZipInputStreamFilter
D: time taken: 485259 . handled 424 apps apks:520
D: averageTime:1144.4788 per app 933.19037 per APK

(time is in ms)

In short:
ZipFile of the Framework is almost x3 times faster than the library here.
However, the ZipArchiveInputStream of the library is a bit more than x2 times 
faster than ZipInputStream of the Android framework.

Any idea how could that be?

Attached project here:

 [^apkParser.zip] 

> Provide an API that can read ZIP archives in two passes over a stream
> ---------------------------------------------------------------------
>
>                 Key: COMPRESS-508
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-508
>             Project: Commons Compress
>          Issue Type: Improvement
>          Components: Archivers
>    Affects Versions: 1.20
>         Environment: Android 9 and Android 10, on both emulator and real 
> device .
>            Reporter: AD_LB
>            Priority: Major
>              Labels: zip
>         Attachments: 2020-03-31_20-53-36.png, 2020-04-01_18-28-19.mp4, 
> ZipTest.zip, ZipTest2.zip, ZipTest3.zip, apkParser.zip, test.zip
>
>
> I'm trying to use ZipArchiveInputStream to iterate over the items of a zip 
> file (which may or may not be a real file on the file-system, which is why I 
> use a stream), optionally creating a stream from specific entries.
> One of the operations I need is to get the size of the files within.
> For some reason, it fails to do so. Not only that, but it throws an exception 
> when I'm done with it:
> {code:java}
> Error:org.apache.commons.compress.archivers.zip.UnsupportedZipFeatureException:
>  Unsupported feature data descriptor used in entry ...
> {code}
> I've attached here 3 files:sample project, the problematic zip file (remember 
> that you need to put it in the correct path and grant storage permission), 
> and a screenshot of the issue.
> Note that if I open the file using a third party PC app (such as 
> [7-zip|https://www.7-zip.org/]  ), it works fine, including showing the file 
> size inside.
> Files:
> !2020-03-31_20-53-36.png![^test.zip]
> [^ZipTest.zip]
> Here's the relevant code (kotlin) :
>  
> {code:java}
>         thread {
>             try {
>                 val file = File("/storage/emulated/0/test.zip")
>                 ZipArchiveInputStream(FileInputStream(file)).use {
>                     while (true) {
>                         val entry = it.nextEntry ?: break
>                         Log.d("AppLog", "entry:${entry.name} ${entry.size} ")
>                     }
>                 }
>                 Log.d("AppLog", "got archive ")
>             } catch (e: Exception) {
>                 Log.d("AppLog", "Error:$e")
>                 e.printStackTrace()
>             }
>         }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to