most efficient way to zip files using coldfusion or java

1.4k Views Asked by At

I'm looking for the most memory efficient way to zip many large files using ColdFusion or Java. I have tried using <cfzip> and using zip.cfc by Nate Nielsen (http://farmancreative.com/womenskiteboarding/admin/dccom/components/dcFileManagerV3/actions/cfc/zip.cfc). For the tests I zipped up a directory that contains 80 mp4 files totaling 1.18GB. The results are below. I could not tell a difference at all when the <cfzip> tag was running, the normal "steps" of ColdFusion appeared unchanged. But with zip.cfc it was more "saw tooth" memory usage.

So my question is, which is the better result? Or is there another newer way that I don't know about that is better than both of these?

I care more about memory usage than speed. But as far as speed goes, <cfzip> was a little faster. <cfzip> time was 100,871. zip.cfc time was 141,285.

Thanks!enter image description here

<cfzip> Test Code:

<cfoutput>
    <cfset tBegin = GetTickCount()>
    <cfzip
        action="zip"
        source="#dir#"
        file="#zipFile#"
        storepath="false"
        overwrite="true"
        />
    <cfset tEnd = GetTickCount()>
    <cfset scriptTime = (tEnd - tBegin)>
    Script Time: #scriptTime#
</cfoutput>

zip.cfc Test Code:

<cfdirectory directory="#dir#" name="d" recurse="false">
<cfoutput>
    <cfset tBegin = GetTickCount()>
    <cfset zipper = createObject("component", "zip")>
    <cfscript>zipper.newZip(zipFile);</cfscript>
    <cfloop query="d">
        <cfset zipper.addFile(dir&d.name)>
    </cfloop>
    <cfscript>zipper.createZip();</cfscript>
    <cfset tEnd = GetTickCount()>
    <cfset scriptTime = (tEnd - tBegin)>
    Script Time: #scriptTime#
</cfoutput>
1

There are 1 best solutions below

1
On

I have to run so can't type much right now but will come back to this tomorrow. Here are my test results after running it against real world file types (.txt, .ppt, .doc, .swf, etc...). Looks like <cfzip> is much better than zip.cfc.enter image description here