[
  {
    "Id": "277119",
    "ThreadId": "80819",
    "Html": "<p>I have included&nbsp;your DotNetZip utility (version 1.8) into a VB.net 2008 (win forms) program.</p>\r\n<p>I run this program daily 12:01am and it zips thousands of files into a daily zip folder. (YYYY-MM-DD.zip format).</p>\r\n<p>Last night it zipped 8,319 files.&nbsp; It took 23 seconds to load the file names into a DataTable, where as it took 9 minutes 35 seconds to load those same file names into a List(Of T) structure that was passed to the UpdateFiles function like the following:&nbsp; zip.UpdateFiles(FileList.ToArray, &quot;&quot;).</p>\r\n<p>As the number of files goes up, it exponentially takes longer to load the List(of t) structure. e.g. 11,000 files takes approximately 15 minutes.</p>\r\n<p>If I could simply pass a single column DataTable into the UpdateFiles function, I think you can see how much time would&nbsp;be saved.</p>\r\n<p>Maybe you know of a faster method that I'm just not aware of?&nbsp; Thanks in advance for any advice you might be able to give.</p>",
    "PostedDate": "2010-01-14T05:56:48.103-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "277236",
    "ThreadId": "80819",
    "Html": "<p>Hmm, let's see.&nbsp; Are you saying that it takes your code&nbsp;over 9 minutes to create a List&lt;String&gt;?&nbsp;&nbsp; You're not saying that it takes a lot of time for DotNetZip to do something.&nbsp; You're saying that it takes a lot of time for your own code to prepare a data structure that will eventually be used in a call to DotNetZip.&nbsp; Is that right?</p>\r\n<p>If so, that seems really slow - there is absolutely something amiss in your code.&nbsp; I just tried and on my machine it takes less than 0.06s to create a list of 9000 randomly generated strings.&nbsp; In other words, your code that builds a list&nbsp;is running 10,000 times slower than mine.</p>\r\n<p>Are you, by chance, querying the filesystem for each file?&nbsp; Querying the database (you mentioned a datatable)?&nbsp; Look for something unusual that is causing the delay.&nbsp; Use a finer-grained analysis to figure out where in your code the 9 minutes is coming from.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-01-14T10:35:13.657-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "277250",
    "ThreadId": "80819",
    "Html": "<p>If yours goes that fast, there must certainly be something wrong in my code.&nbsp;</p>\r\n<p>What I'm doing is taking the filenames from a directory and based on the last-modified date of each file am assigning it a zip file name which I'm loading into a DataTable.&nbsp; The columns of my DataTable&nbsp;are: ZipFileName, FileName, LastModifyDate.&nbsp; I&nbsp;sort my DataTable in the order of those 3 columns.</p>\r\n<p>I loop through the DataTable&nbsp;to build my List&lt;String&gt; structure and Call the DotNetZip code when the ZipFileName changes.</p>\r\n<p>The DotNetZip code itself is working nicely.&nbsp; It&nbsp;zipped the 8,319 files in 2 min. 21 seconds.</p>\r\n<p>I'll have to dig deeper into my code to see what could be causing the delay.&nbsp;</p>\r\n<p>Would you mind posting&nbsp;your&nbsp;snippet of code for generating the 9000 strings?&nbsp; I would like to run that on my end, just to see how long&nbsp;it takes.</p>\r\n<p>Thanks, Dave</p>",
    "PostedDate": "2010-01-14T11:05:37.16-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "277274",
    "ThreadId": "80819",
    "Html": "<p>No problem Dave.</p>\r\n<p>Here's the code I used to measure the performance of List&lt;String&gt;:</p>\r\n<p><a href=\"http://cheeso.members.winisp.net/srcview.aspx?file=ListTest.cs\">http://cheeso.members.winisp.net/srcview.aspx?file=ListTest.cs</a></p>\r\n<p>The snip that's interesting:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre>\r\n<span style=\"color:Green\">// Time an operation. This method accepts a single argument.</span>\r\n<span style=\"color:Green\">// The argument is a Func&lt;&gt; (a delegate) that accepts NO</span>\r\n<span style=\"color:Green\">// arguments, and returns a List&lt;String&gt;.  This method starts a</span>\r\n<span style=\"color:Green\">// stopwatch, invokes the delegate, then stops the stopwatch.</span>\r\n<span style=\"color:Blue\">private</span> <span style=\"color:Blue\">double</span> TimedOperation(<span style=\"color:Blue\">int</span> trial, Func&lt;List&lt;String&gt;&gt; a)\r\n{\r\n    <span style=\"color:Blue\">var</span> timer= <span style=\"color:Blue\">new</span> System.Diagnostics.Stopwatch();\r\n    timer.Start();\r\n    a();\r\n    timer.Stop();\r\n    System.Console.WriteLine(<span style=\"color:#A31515\">&quot;  trial {0}: elapsed time: {1:N4}s&quot;</span>, trial, timer.Elapsed.TotalSeconds);\r\n    <span style=\"color:Blue\">return</span> timer.Elapsed.TotalSeconds;\r\n}\r\n\r\n\r\n<span style=\"color:Blue\">public</span> List&lt;String&gt; FillList()\r\n{\r\n    <span style=\"color:Blue\">var</span> list = <span style=\"color:Blue\">new</span> List&lt;String&gt;();\r\n    <span style=\"color:Blue\">for</span> (<span style=\"color:Blue\">int</span> i=0; i&lt;_numEntries;  i++)\r\n    {\r\n        <span style=\"color:Green\">// pick a length, between 17 and 81</span>\r\n        <span style=\"color:Blue\">int</span> length = _rnd.Next(64) + 17;\r\n        <span style=\"color:Green\">// generate a string of that length</span>\r\n        <span style=\"color:Blue\">var</span> s = GenerateRandomAsciiString(length);\r\n        <span style=\"color:Green\">// add that string to the list</span>\r\n        list.Add(s);\r\n    }\r\n\r\n    <span style=\"color:Blue\">return</span> list;\r\n}\r\n\r\n<span style=\"color:Blue\">public</span> <span style=\"color:Blue\">void</span> Run()\r\n{\r\n    System.Console.WriteLine(<span style=\"color:#A31515\">&quot;Testing the filling of List&lt;String&gt; with {0} entries ({1} cycles)&quot;</span>,\r\n                             _numEntries, _nCycles);\r\n\r\n    <span style=\"color:Blue\">double</span> totalTime = 0.0;\r\n    Console.WriteLine();\r\n    Console.WriteLine(<span style=\"color:Blue\">new</span> String(<span style=\"color:#A31515\">'='</span>,55));\r\n    <span style=\"color:Blue\">for</span> (<span style=\"color:Blue\">int</span> i=0; i&lt;_nCycles+1; i++)\r\n    {\r\n        totalTime += TimedOperation(i, FillList);\r\n        <span style=\"color:Green\">// throw out the first trial.</span>\r\n        <span style=\"color:Blue\">if</span> (i==0) totalTime = 0.0;\r\n    }\r\n    Console.WriteLine(<span style=\"color:Blue\">new</span> String(<span style=\"color:#A31515\">'='</span>,55));\r\n    Console.WriteLine(<span style=\"color:#A31515\">&quot;  avg (excluding 0th trial): {0,7:F4}s&quot;</span>, totalTime / _nCycles);\r\n}\r\n\r\n\r\n</pre>\r\n</div>",
    "PostedDate": "2010-01-14T11:54:55.03-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "277282",
    "ThreadId": "80819",
    "Html": "<p>Whoops - here it is in a VB Console application</p>\r\n<p><a href=\"http://cheeso.members.winisp.net/srcview.aspx?file=ListTest.VB.vb\">http://cheeso.members.winisp.net/srcview.aspx?file=ListTest.VB.vb</a></p>\r\n<p>the interesting parts:</p>\r\n<div style=\"color:Black;background-color:White\">\r\n<pre><span style=\"color:Blue\">Public</span> <span style=\"color:Blue\">Function</span> FillList() <span style=\"color:Blue\">As</span> List(Of <span style=\"color:Blue\">String</span>)\r\n    <span style=\"color:Blue\">Dim</span> list <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">New</span> List(Of <span style=\"color:Blue\">String</span>)\r\n    <span style=\"color:Blue\">Dim</span> i <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span>\r\n    <span style=\"color:Blue\">For</span> i = 0 <span style=\"color:Blue\">To</span> <span style=\"color:Blue\">Me</span>._numEntries - 1\r\n        <span style=\"color:Blue\">Dim</span> length <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span> = (<span style=\"color:Blue\">Me</span>._rnd.<span style=\"color:Blue\">Next</span>(&amp;H40) + &amp;H11)\r\n        <span style=\"color:Blue\">Dim</span> item <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">String</span> = <span style=\"color:Blue\">Me</span>.GenerateRandomAsciiString(length)\r\n        list.Add(item)\r\n    <span style=\"color:Blue\">Next</span> i\r\n    <span style=\"color:Blue\">Return</span> list\r\n<span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Function</span>\r\n\r\n<span style=\"color:Blue\">Private</span> <span style=\"color:Blue\">Function</span> TimedOperation(<span style=\"color:Blue\">ByVal</span> trial <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span>, <span style=\"color:Blue\">ByVal</span> a <span style=\"color:Blue\">As</span> Func(Of List(Of <span style=\"color:Blue\">String</span>))) <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Double</span>\r\n    <span style=\"color:Blue\">Dim</span> stopwatch <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">New</span> Stopwatch\r\n    stopwatch.Start\r\n    a.Invoke\r\n    stopwatch.<span style=\"color:Blue\">Stop</span>\r\n    Console.WriteLine(<span style=\"color:#A31515\">&quot;  trial {0}: elapsed time: {1:N4}s&quot;</span>, trial, stopwatch.Elapsed.TotalSeconds)\r\n    <span style=\"color:Blue\">Return</span> stopwatch.Elapsed.TotalSeconds\r\n<span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Function</span>\r\n\r\n<span style=\"color:Blue\">Public</span> <span style=\"color:Blue\">Sub</span> Run()\r\n    Console.WriteLine(<span style=\"color:#A31515\">&quot;Testing the filling of List&lt;String&gt; with {0} entries ({1} cycles)&quot;</span>, <span style=\"color:Blue\">Me</span>._numEntries, <span style=\"color:Blue\">Me</span>._nCycles)\r\n    <span style=\"color:Blue\">Dim</span> num <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Double</span> = 0\r\n    Console.WriteLine\r\n    Console.WriteLine(<span style=\"color:Blue\">New</span> <span style=\"color:Blue\">String</span>(<span style=\"color:#A31515\">&quot;=&quot;</span>c, &amp;H37))\r\n    <span style=\"color:Blue\">Dim</span> i <span style=\"color:Blue\">As</span> <span style=\"color:Blue\">Integer</span>\r\n    <span style=\"color:Blue\">For</span> i = 0 <span style=\"color:Blue\">To</span> (<span style=\"color:Blue\">Me</span>._nCycles + 1) - 1\r\n        num = (num + <span style=\"color:Blue\">Me</span>.TimedOperation(i, <span style=\"color:Blue\">New</span> Func(Of List(Of <span style=\"color:Blue\">String</span>))(<span style=\"color:Blue\">AddressOf</span> <span style=\"color:Blue\">Me</span>.FillList)))\r\n        <span style=\"color:Blue\">If</span> (i = 0) <span style=\"color:Blue\">Then</span>\r\n            num = 0\r\n        <span style=\"color:Blue\">End</span> <span style=\"color:Blue\">If</span>\r\n    <span style=\"color:Blue\">Next</span> i\r\n    Console.WriteLine(<span style=\"color:Blue\">New</span> <span style=\"color:Blue\">String</span>(<span style=\"color:#A31515\">&quot;=&quot;</span>c, &amp;H37))\r\n    Console.WriteLine(<span style=\"color:#A31515\">&quot;  avg (excluding 0th trial): {0,7:F4}s&quot;</span>, (num / <span style=\"color:Blue\">CDbl</span>(<span style=\"color:Blue\">Me</span>._nCycles)))\r\n<span style=\"color:Blue\">End</span> <span style=\"color:Blue\">Sub</span>\r\n\r\n</pre>\r\n</div>\r\n<p>&nbsp;</p>",
    "PostedDate": "2010-01-14T12:10:07.353-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "277291",
    "ThreadId": "80819",
    "Html": "<p>Thanks for including the VB.&nbsp; I'll let you know what I find out.</p>",
    "PostedDate": "2010-01-14T12:34:01.76-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "278572",
    "ThreadId": "80819",
    "Html": "<p>This was&nbsp;was definately a coding error&nbsp;on my behalf.&nbsp; Thanks for all your help in pointing me in the right direction!</p>",
    "PostedDate": "2010-01-18T09:29:34.01-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "278599",
    "ThreadId": "80819",
    "Html": "<p>you're welcome. glad you figured it out.</p>",
    "PostedDate": "2010-01-18T11:32:09.043-08:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]